HTTP Post Doesnt work in ASP.NET page

A

Arfeen

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.Text.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 !!!!
 
A

Arfeen

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?

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 said:
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.Text.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 !!!!
 

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,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top