Getting 401 Unauthorized error using WebClient UploadFile method

Getting 401 Unauthorized error using WebClient UploadFile method

Post by Horus Alkebula » Wed, 30 Apr 2003 21:58:06



Running on development platform where all on XP Pro, no domain controller.

When I call this code from my windows forms client

--- snip ---
Dim uriString As String =
"http://localhost/IDSM_WebService/uploads/wireless1.doc"

' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient()
Dim fileName As String = "c:\wireless1.doc"

' Upload the file to the Url using the HTTP 1.0 POST.
Dim responseArray As Byte() = myWebClient.UploadFile(uriString, "PUT",
fileName)

' Decode and display the response.
str = "Response Received.The contents of the file uploaded are: " &
System.Text.Encoding.ASCII.GetString(responseArray)

--- snip ---

I get this error. Any ideas?

   An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
   Additional information: The remote server returned an error: (401)
Unauthorized.

TIA

 
 
 

Getting 401 Unauthorized error using WebClient UploadFile method

Post by User » Wed, 30 Apr 2003 23:40:06


possibly you do not have write permission on the virtual directory.
you would need both NT file permission and enable writes in the IIS virtual
directory manager


Quote:> Running on development platform where all on XP Pro, no domain controller.

> When I call this code from my windows forms client

> --- snip ---
> Dim uriString As String =
> "http://localhost/IDSM_WebService/uploads/wireless1.doc"

> ' Create a new WebClient instance.
> Dim myWebClient As New System.Net.WebClient()
> Dim fileName As String = "c:\wireless1.doc"

> ' Upload the file to the Url using the HTTP 1.0 POST.
> Dim responseArray As Byte() = myWebClient.UploadFile(uriString, "PUT",
> fileName)

> ' Decode and display the response.
> str = "Response Received.The contents of the file uploaded are: " &
> System.Text.Encoding.ASCII.GetString(responseArray)

> --- snip ---

> I get this error. Any ideas?

>    An unhandled exception of type 'System.Net.WebException' occurred in
> system.dll
>    Additional information: The remote server returned an error: (401)
> Unauthorized.

> TIA


 
 
 

Getting 401 Unauthorized error using WebClient UploadFile method

Post by Horus Alkebula » Thu, 01 May 2003 22:18:13


The web site upload folder path is
c:\inetpub\wwwroot\IDSM_WebService\uploads. I have Allow Modify permissions
on this folder for "Users".

The root of the website is http://localhost/IDSM_WebService/. The files are
being posted to http://localhost/IDSM_WebService/Uploads/.

In the virtual directory settings of the "Uploads" folder, I have "Write"
checked. I have Integrated Authentication checked and Anonymous unchecked.

Not sure what else to do.

Thanks!


> possibly you do not have write permission on the virtual directory.
> you would need both NT file permission and enable writes in the IIS
virtual
> directory manager



> > Running on development platform where all on XP Pro, no domain
controller.

> > When I call this code from my windows forms client

> > --- snip ---
> > Dim uriString As String =
> > "http://localhost/IDSM_WebService/uploads/wireless1.doc"

> > ' Create a new WebClient instance.
> > Dim myWebClient As New System.Net.WebClient()
> > Dim fileName As String = "c:\wireless1.doc"

> > ' Upload the file to the Url using the HTTP 1.0 POST.
> > Dim responseArray As Byte() = myWebClient.UploadFile(uriString, "PUT",
> > fileName)

> > ' Decode and display the response.
> > str = "Response Received.The contents of the file uploaded are: " &
> > System.Text.Encoding.ASCII.GetString(responseArray)

> > --- snip ---

> > I get this error. Any ideas?

> >    An unhandled exception of type 'System.Net.WebException' occurred in
> > system.dll
> >    Additional information: The remote server returned an error: (401)
> > Unauthorized.

> > TIA

 
 
 

Getting 401 Unauthorized error using WebClient UploadFile method

Post by Kevi » Fri, 16 May 2003 01:42:49


If you have Integrated Authentication enabled, then you need to set
the Credentials property of the WebClient.

myWebClient.Credentials = new System.Net.NetworkCredential("username",
"password", "domain")

Then you can make the call to UploadFile.


> The web site upload folder path is
> c:\inetpub\wwwroot\IDSM_WebService\uploads. I have Allow Modify permissions
> on this folder for "Users".

> The root of the website is http://localhost/IDSM_WebService/. The files are
> being posted to http://localhost/IDSM_WebService/Uploads/.

> In the virtual directory settings of the "Uploads" folder, I have "Write"
> checked. I have Integrated Authentication checked and Anonymous unchecked.

> Not sure what else to do.

> Thanks!



> > possibly you do not have write permission on the virtual directory.
> > you would need both NT file permission and enable writes in the IIS
>  virtual
> > directory manager



> > > Running on development platform where all on XP Pro, no domain
>  controller.

> > > When I call this code from my windows forms client

> > > --- snip ---
> > > Dim uriString As String =
> > > "http://localhost/IDSM_WebService/uploads/wireless1.doc"

> > > ' Create a new WebClient instance.
> > > Dim myWebClient As New System.Net.WebClient()
> > > Dim fileName As String = "c:\wireless1.doc"

> > > ' Upload the file to the Url using the HTTP 1.0 POST.
> > > Dim responseArray As Byte() = myWebClient.UploadFile(uriString, "PUT",
> > > fileName)

> > > ' Decode and display the response.
> > > str = "Response Received.The contents of the file uploaded are: " &
> > > System.Text.Encoding.ASCII.GetString(responseArray)

> > > --- snip ---

> > > I get this error. Any ideas?

> > >    An unhandled exception of type 'System.Net.WebException' occurred in
> > > system.dll
> > >    Additional information: The remote server returned an error: (401)
> > > Unauthorized.

> > > TIA

 
 
 

1. Getting 401 Unauthorized error using WebClient UploadFile method

Running on development platform where all on XP Pro, no domain controller.

When I call this code from my windows forms client

--- snip ---
Dim uriString As String =
"http://localhost/IDSM_WebService/uploads/wireless1.doc"

' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient()
Dim fileName As String = "c:\wireless1.doc"

' Upload the file to the Url using the HTTP 1.0 POST.
Dim responseArray As Byte() = myWebClient.UploadFile(uriString, "PUT",
fileName)

' Decode and display the response.
str = "Response Received.The contents of the file uploaded are: " &
System.Text.Encoding.ASCII.GetString(responseArray)

--- snip ---

I get this error. Any ideas?

   An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
   Additional information: The remote server returned an error: (401)
Unauthorized.

TIA

2. Fax server on windows2000 server

3. (401) Unauthorized error when calling XmlTextReader.

4. Trouble installing software on E-15

5. Error in asp .net "the request failed with HTTP status 401:Unauthorized"

6. Crashing when entering Frames wizard

7. HTTPWebRequest.request.GetResponse fails: remote server returned error: (401) unauthorized.

8. Spell Check

9. Unauthorized (401) Error

10. WebClient.UploadFile() and WebClient.DownloadFile()

11. Http 401 : request unauthorized

12. The request failed with HTTP status 401: Unauthorized - MS I need your help!!