Webrequest not working.

  • Thread starter Thread starter archana
  • Start date Start date
A

archana

Hi all,
I am having application which is validating URL's and checking whether
that URL is redirecting to some other URL at a time of opening or not.

My code looks like:-

WebRequest myWebRequest = WebRequest.Create(textBox1.Text);
response. myWebResponse = myWebRequest.GetResponse();
MssageBox.Show(myWebResponse.ResponseUri.ToString());

But sometimes i am getting error :-
The remote server returned an error: (500) Internal Server Error.
and
The remote server returned an error: (403) Forbidden.

But if i check that url in IE those URL's are opening properly but not
through above code.

Can someone tell me why this is happening.

Please help me asap.

thanks in advance.
 
* archana said:
Hi all,
I am having application which is validating URL's and checking whether
that URL is redirecting to some other URL at a time of opening or not.

My code looks like:-

WebRequest myWebRequest = WebRequest.Create(textBox1.Text);
response. myWebResponse = myWebRequest.GetResponse();
MssageBox.Show(myWebResponse.ResponseUri.ToString());

But sometimes i am getting error :-
The remote server returned an error: (500) Internal Server Error.
and
The remote server returned an error: (403) Forbidden.

http://www.checkupdown.com/status/E403.html
 
Hi,

thanks for ur reply.

If i try to browse that URL in IE6 it is opening properly but not
throuhg above code.

Can you tell me why this is happening.

Thanks
 
Thus wrote archana,
Hi all,
I am having application which is validating URL's and checking whether
that URL is redirecting to some other URL at a time of opening or not.
My code looks like:-

WebRequest myWebRequest = WebRequest.Create(textBox1.Text); response.
myWebResponse = myWebRequest.GetResponse();
MssageBox.Show(myWebResponse.ResponseUri.ToString());

But sometimes i am getting error :-
The remote server returned an error: (500) Internal Server Error.
and
The remote server returned an error: (403) Forbidden.
But if i check that url in IE those URL's are opening properly but not
through above code.

Can someone tell me why this is happening.

You neither pass any credentials nor do you specify some HTTP headers web
applications might try use, e.g. User-Agent to identify a client's browser
type.

Compare the HTTP requests sent by IE to your requests using Fiddler (www.fiddertool.com).

Cheers,
 
That url doesn't work for me.

--

________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
 

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

Back
Top