473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

errors running HttpWebRequest.GetResponse - 401 unauthorized

I have a page that uses simple HTTP GET to do an ISBN lookup via
Amazon.com. The page works when I run it from //localhost. But I have
moved it to my godaddy.com shared hoster site, and I get errors on the
HttpWebRequest.GetResponse statement.

The remote server returned an error: (401) Unauthorized

also, when I use the network credentials object in the context of my
request, I get this error:

The underlying connection was closed: The server committed
an HTTP protocol violation.

Here is the web page I have prepared as I do battle with the godaddy
techs.
www.autocoder.com/demosite/AmazonQuery.aspx

click away at it, I dont think any harm can be done.

A code snippet follows. I am working under the assumption that the
problem resides with the config of the godaddy servers. Is there
something that has to be enabled in order for my asp.net code to send a
web request to another site? Are there magic words I can use to
convince the godaddy techs to this affect?

thanks,

-Steve

private void WebRequestTest( string InURL )
{
string line ;
StringBuilder sb = new StringBuilder( ) ;
HttpWebResponse resp ;
HttpWebRequest rqs = (HttpWebRequest)WebRequest.Create( InURL ) ;
rqs.MaximumAutomaticRedirections = 4;
rqs.MaximumResponseHeadersLength = 4;
// either user default credentials or the credentials specified on the
page.
if ( CheckBox1.Checked == false )
rqs.Credentials = CredentialCache.DefaultCredentials;
else
rqs.Credentials = new NetworkCredential( tbUser.Text,
tbPassword.Text, tbDomain.Text ) ;

// send the request to the remote site, get the response.
resp = (HttpWebResponse)rqs.GetResponse( ) ;

Nov 19 '05 #1
2 14054
this error was corrected by godaddy providing me with a url of a proxy
server to use on my web requests:

HttpWebResponse resp = null ;
HttpWebRequest rqs = (HttpWebRequest)WebRequest.Create( InURL ) ;
string ProxyUrl = ConfigurationSettings.AppSettings["WebRequestProxy"]
;
if ( ProxyUrl != null )
{
WebProxy proxy = new WebProxy( ProxyUrl ) ;
rqs.Proxy = proxy ;
}
resp = (HttpWebResponse)rqs.GetResponse( ) ;

-Steve

Steve Richter wrote:
I have a page that uses simple HTTP GET to do an ISBN lookup via
Amazon.com. The page works when I run it from //localhost. But I have moved it to my godaddy.com shared hoster site, and I get errors on the HttpWebRequest.GetResponse statement.

The remote server returned an error: (401) Unauthorized

also, when I use the network credentials object in the context of my
request, I get this error:

The underlying connection was closed: The server committed
an HTTP protocol violation.

Here is the web page I have prepared as I do battle with the godaddy
techs.
www.autocoder.com/demosite/AmazonQuery.aspx

click away at it, I dont think any harm can be done.

A code snippet follows. I am working under the assumption that the
problem resides with the config of the godaddy servers. Is there
something that has to be enabled in order for my asp.net code to send a web request to another site? Are there magic words I can use to
convince the godaddy techs to this affect?

thanks,

-Steve

private void WebRequestTest( string InURL )
{
string line ;
StringBuilder sb = new StringBuilder( ) ;
HttpWebResponse resp ;
HttpWebRequest rqs = (HttpWebRequest)WebRequest.Create( InURL ) ;
rqs.MaximumAutomaticRedirections = 4;
rqs.MaximumResponseHeadersLength = 4;
// either user default credentials or the credentials specified on the page.
if ( CheckBox1.Checked == false )
rqs.Credentials = CredentialCache.DefaultCredentials;
else
rqs.Credentials = new NetworkCredential( tbUser.Text,
tbPassword.Text, tbDomain.Text ) ;

// send the request to the remote site, get the response.
resp = (HttpWebResponse)rqs.GetResponse( ) ;


Nov 19 '05 #2
"Steve Richter" <St************@gmail.com> wrote in message
news:St************@gmail.com:
also, when I use the network credentials object in the context of my
request, I get this error:

The underlying connection was closed: The server committed
an HTTP protocol violation.


It sounds like you're using 1.1... If so, try this in your config file:

<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>

It seems most servers break the RFC and use spaces in their headers.
useUnsafeHeaderParsing fixed the problem for me...

-shane

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Satinderpal Singh | last post by:
Hi everyone, We are using HttpWebRequest to create a request to a URI, which requires us to login first. In order to process all the transactions, first we have to login and get the cookie value...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
3
by: ME | last post by:
Hi; I am getting "Unhandled Exception: System.Net.WebException: The remote server returned an erro r: (401) Unauthorized." when I am trying to get a page via post. Code follows...
0
by: Dave | last post by:
Hi, I'm trying to make a WebRequest to url using the code below. The url points to a large number XML files on my shared dev server via a virtual folder secured using basic authentication. I did...
1
by: Satinderpal Singh | last post by:
Hi everyone, We are using HttpWebRequest to create a request to a URI, which requires us to login first. In order to process all the transactions, first we have to login and get the cookie value...
0
by: Pmcg | last post by:
I would appreciate any help with the following, havn't found any answers for this in my research to date. I am trying to retreive a web page (a htm file intially) from a vdir on an intranet site...
0
by: Cozfer | last post by:
I am having a problem communicating with a remote server (on intranet) using the httpwebrequest object. We have used the object to communicate with other machines previously, but this time we must...
2
by: neoret | last post by:
I don't get any further on this - pleas help me :) In c# I'm using the httpWebRequest object to post a word-document along with some parameters to a server. My challenges are: 1. When creating...
0
by: ashurack | last post by:
I can't seem to get this to work. The URL I want to access is protected with windows authentication. I thought that was NTLM but the following isn't working: string url =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.