Connecting Tech Pros Worldwide Help | Site Map

HTTP Post Doesnt work in ASP.NET page

Arfeen
Guest
 
Posts: n/a
#1: Dec 5 '06
Hi All,

I need help again .....

I have an asp.net web page which I hit using the "HTTP POST" method.

My ASP.NET page is a basic hello world example with the following code:

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("Hello World");
Response.End();
}


Then I use a C# desktop application to HTTP POST some data to this web
site. I use the following code to post data:

System.Net.WebRequest req =
System.Net.WebRequest.Create("http://localhost/proj/page.aspx");
req.Timeout = 20000; //timeout = 20 secnds.

//Add these, as we're doing a POST
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
//We need to count how many bytes we're sending.
byte [] bytes =
HttpUtility.UrlEncodeToBytes(Parameters,System.Tex t.ASCIIEncoding.ASCII);//System.Text.Encoding.ASCII.GetBytes(DATA);
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream ();
os.Write (bytes, 0, bytes.Length); //Push it out there
os.Close ();
System.Net.WebResponse resp = req.GetResponse();

My application works perfectly fine on our test servers and a couple of
customer sites , but Im having a problem with one customer, my HTTP
POST messages return the '500 - Internal Server Error'.
And when I browse to the url using internet explorer, I dont get that
error.
So it seems like HTTP GET is working, but HTTP POST does not.

Does anybody have any ideas about what could be wrong here. Is there
some setting that I need to fix in the IIS manager or the security
policies?

Please Help !!!!

Arfeen
Guest
 
Posts: n/a
#2: Dec 6 '06

re: HTTP Post Doesnt work in ASP.NET page


When I try to POST to the site, this is the exception that i get in my
desktop HTTP Post application:

System.Net.WebException
"The remote server returned an error: (500) Internal Server Error."

I have complete access to the customer web server, can u tell me how
can I check what sort of exception is being generated on the customer
server?


Ciaran O''Donnell wrote:
Quote:
The site probably expects some sort of post data when posted to and doesnt
handle not getting. Cant you speak to the customer to ask them what the
exception was?
--
Ciaran O'Donnell
http://wannabedeveloper.spaces.live.com
>
>
"Arfeen" wrote:
>
Quote:
Hi All,

I need help again .....

I have an asp.net web page which I hit using the "HTTP POST" method.

My ASP.NET page is a basic hello world example with the following code:

private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("Hello World");
Response.End();
}


Then I use a C# desktop application to HTTP POST some data to this web
site. I use the following code to post data:

System.Net.WebRequest req =
System.Net.WebRequest.Create("http://localhost/proj/page.aspx");
req.Timeout = 20000; //timeout = 20 secnds.

//Add these, as we're doing a POST
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
//We need to count how many bytes we're sending.
byte [] bytes =
HttpUtility.UrlEncodeToBytes(Parameters,System.Tex t.ASCIIEncoding.ASCII);//System.Text.Encoding.ASCII.GetBytes(DATA);
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream ();
os.Write (bytes, 0, bytes.Length); //Push it out there
os.Close ();
System.Net.WebResponse resp = req.GetResponse();

My application works perfectly fine on our test servers and a couple of
customer sites , but Im having a problem with one customer, my HTTP
POST messages return the '500 - Internal Server Error'.
And when I browse to the url using internet explorer, I dont get that
error.
So it seems like HTTP GET is working, but HTTP POST does not.

Does anybody have any ideas about what could be wrong here. Is there
some setting that I need to fix in the IIS manager or the security
policies?

Please Help !!!!
Closed Thread