Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
i used this coding in asp.net web application. may be the requestinng arguement(userid and password) is not correct format. i think this blow coding for consol application. how to send those arguement in asp.net web application ? or what is the problem?



C#
public void functionname()
{

HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create("http://xxxxx/function.asmx/login");

myRequest.Method = "POST";

using (StreamWriter requestWriter = new StreamWriter(myRequest.GetRequestStream()))
{

requestWriter.Write("&{0}={1}", HttpUtility.UrlEncode("UserId"), HttpUtility.UrlEncode("christ"));

requestWriter.Write("&{0}={1}", HttpUtility.UrlEncode("Password"), HttpUtility.UrlEncode("christ123"));


}

using (StreamReader responseReader = new StreamReader(myRequest.GetResponse().GetResponseStream())) // here throws internal error. it is not going inside this function.
{

result = responseReader.ReadToEnd();

}

}


I am getting error like below:

The remote server returned an error: (500) Internal Server Error.

how to solve this error.

Note : i tested normal method helloworld (which does not send arguement or sending any rerquest), that one does not face internal error. but if i send any arguement only(userid,password), it throws like " The Remote server returned an error:(500)Internal Server Error.

help needed.
Posted
Updated 12-Feb-14 4:53am
v3

1 solution

You're getting a 500 error back because the code running on the webserver crashes somehow. You apparently did something in your request that the server didn't like, didn't expect, and doesn't know how to handle.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900