Saturday, March 24, 2012

System.Net.Webexecption on WebRequest.GetResponse

Hi Everybody,

after a while, ive had to maintain a ASP.NET/C# project, where
during processing of an request, the same (local!) webserver is
requested again for the response of a corresponding aspx-page.

Something like this:

...
string uri = 'http://localhost/appname/secondpage.aspx?ItemId=4711';
WebRequest req = WebRequest.Create( uri );
req.Credentials = CredentialCache.DefaultCredentials;
WebResponse resp = req.GetResponse();
Stream st = req.GetResponseStream;
...

This worked fine on my machine a few month ago, as well as on my
collegues machine and alos at the customer.
On all 3 machines, the local IIS instance is responsible to process
the aspx-Request (two XP-SP2, one W2k-Server).

Acutally, when i perform this again, ill get a
System.Net.Webexecption
on the execution of "req.GetResponse()" with following error-stack

System.Net.HttpWebRequest.CheckFinalStatus()
System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult)
System.Net.HttpWebRequest.CheckFinalStatus()
myModule.myMethod()
etc. ...

This error appears also, when i replace the uri above f.e. with
'http://www.google.com'.
Even when i run a downloaded, ready-to-use C#-sample (EXE, not
ASP.NET!),
ill get this error.

On my collegues machine, the same things still works fine, even on the
customers
server, but im not able to test/debug this one on my machine anymore.

I dont know, what could be the reason for it.
My XPs configuration seems very identical to my collegues one.
Also my XP Servicepacks, Patches and .NET-Version look identical to
my
collegue ones.
But there must be a difference!

Does anyone has any idea, that maybe can keep me away from a complete
reinstallation of my machine?

Thanks in advance,

ThomasThis exception is also thrown if the statuscode is 404 for example. Have a
look at this:

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebrequestclassendgetresponsetopic.a sp
--
Daniel Fisher(lennybacon)
MCP ASP.NET C#
Blog: http://www.lennybacon.com/

"Thomas Geisel" <tgeisel@.symax.de> wrote in message
news:b455c2e.0501180203.cba6e16@.posting.google.com ...
> Hi Everybody,
> after a while, ive had to maintain a ASP.NET/C# project, where
> during processing of an request, the same (local!) webserver is
> requested again for the response of a corresponding aspx-page.
> Something like this:
> ...
> string uri = 'http://localhost/appname/secondpage.aspx?ItemId=4711';
> WebRequest req = WebRequest.Create( uri );
> req.Credentials = CredentialCache.DefaultCredentials;
> WebResponse resp = req.GetResponse();
> Stream st = req.GetResponseStream;
> ...
> This worked fine on my machine a few month ago, as well as on my
> collegues machine and alos at the customer.
> On all 3 machines, the local IIS instance is responsible to process
> the aspx-Request (two XP-SP2, one W2k-Server).
> Acutally, when i perform this again, ill get a
> System.Net.Webexecption
> on the execution of "req.GetResponse()" with following error-stack
> System.Net.HttpWebRequest.CheckFinalStatus()
> System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult)
> System.Net.HttpWebRequest.CheckFinalStatus()
> myModule.myMethod()
> etc. ...
> This error appears also, when i replace the uri above f.e. with
> 'http://www.google.com'.
> Even when i run a downloaded, ready-to-use C#-sample (EXE, not
> ASP.NET!),
> ill get this error.
> On my collegues machine, the same things still works fine, even on the
> customers
> server, but im not able to test/debug this one on my machine anymore.
> I dont know, what could be the reason for it.
> My XPs configuration seems very identical to my collegues one.
> Also my XP Servicepacks, Patches and .NET-Version look identical to
> my
> collegue ones.
> But there must be a difference!
> Does anyone has any idea, that maybe can keep me away from a complete
> reinstallation of my machine?
> Thanks in advance,
> Thomas

0 comments:

Post a Comment