The remote server returned an error: (401)

G

Guest

Hi,

This is driving me crazy. I have a solution that works great on one site,
but doesn't on another site. Same exact code on two different windows
environments. Here is the code:

Private Sub DoStuff()
Dim sURL As String
Dim XMLnews As XmlDocument = New XmlDocument
Dim XMLroot As System.Xml.XmlElement
Dim XMLHeadline As System.Xml.XmlNode
Dim XMLnode As System.Xml.XmlNode
Dim sFeed As String
Try

sURL = "http://www.microsoft.com/"
Dim myHttpWebRequest As HttpWebRequest =
CType(WebRequest.Create(sURL), HttpWebRequest)
myHttpWebRequest.Proxy = System.Net.WebProxy.GetDefaultProxy

Dim myHttpWebResponse As HttpWebResponse =
CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Dim receiveStream As Stream =
myHttpWebResponse.GetResponseStream()
Dim encode As System.Text.Encoding =
System.Text.Encoding.GetEncoding("utf-8")
Dim readStream As New StreamReader(receiveStream, encode)
skinerror.Text = readStream.ReadToEnd.ToString

Catch ex As Exception
skinerror.Text = ex.Message.ToString & "<br>" &
ex.StackTrace.ToString
End Try

End Sub

On the good site it returns the web page (in this case Microsoft.com's home
page). On the bad site (hosted by godaddy.com) it returns:


The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.CheckFinalStatus() at
System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at
System.Net.HttpWebRequest.GetResponse() at webapp._Default.DoStuff()

I am not using credentials of any kind -- it doesn't matter what website I
point to either.

I'm at a loss -- thanks in advance.
 
B

bruce barker

401 is access denied. as the actual site does not require authenication, the
authenication request is coming from the proxy server. godaddy's proxy may
complety block outgoing traffic, or may require a login. check with their
technical support


-- bruce (sqlwork.com)


| Hi,
|
| This is driving me crazy. I have a solution that works great on one site,
| but doesn't on another site. Same exact code on two different windows
| environments. Here is the code:
|
| Private Sub DoStuff()
| Dim sURL As String
| Dim XMLnews As XmlDocument = New XmlDocument
| Dim XMLroot As System.Xml.XmlElement
| Dim XMLHeadline As System.Xml.XmlNode
| Dim XMLnode As System.Xml.XmlNode
| Dim sFeed As String
| Try
|
| sURL = "http://www.microsoft.com/"
| Dim myHttpWebRequest As HttpWebRequest =
| CType(WebRequest.Create(sURL), HttpWebRequest)
| myHttpWebRequest.Proxy = System.Net.WebProxy.GetDefaultProxy
|
| Dim myHttpWebResponse As HttpWebResponse =
| CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
| Dim receiveStream As Stream =
| myHttpWebResponse.GetResponseStream()
| Dim encode As System.Text.Encoding =
| System.Text.Encoding.GetEncoding("utf-8")
| Dim readStream As New StreamReader(receiveStream, encode)
| skinerror.Text = readStream.ReadToEnd.ToString
|
| Catch ex As Exception
| skinerror.Text = ex.Message.ToString & "<br>" &
| ex.StackTrace.ToString
| End Try
|
| End Sub
|
| On the good site it returns the web page (in this case Microsoft.com's
home
| page). On the bad site (hosted by godaddy.com) it returns:
|
|
| The remote server returned an error: (401) Unauthorized.
| at System.Net.HttpWebRequest.CheckFinalStatus() at
| System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at
| System.Net.HttpWebRequest.GetResponse() at webapp._Default.DoStuff()
|
| I am not using credentials of any kind -- it doesn't matter what website I
| point to either.
|
| I'm at a loss -- thanks in advance.
|
 
G

Guest

I have a request into them about exactly that. If it is a proxy, how would I
setup the code the use the username/password properly?

Thanks for the response

Paul
 
G

Guest

Well, this is getting ridiculous....

The host says their proxy works fine -- no authentication.

Why doesn't micorosoft provide details on the authentication issue ??????

Such as "where" the 401 is received from ?

Anyone with advanced knowledge of this type of issue would be helpful...

thanks,
paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top