I'm not sure why but in my asp.net project in this code block when i get an exception on GetRequestStream() i cannot move my cursor to another point in the function as i normally do when i get a function.
The reason is Unable to set the next statement to this location. The next statement cannot be set to another function.
Is there something i can do to allow this?
static public CookieContainer login(string user, string pass)
{
var cookie = new CookieContainer();
var request = (HttpWebRequest)HttpWebRequest.Create(@"https://www.somesite.com/users/login");
request.CookieContainer = cookie;
{
var postData = string.Format("ref=http://www.somesite.com/&username={0}&password={1}", user, pass);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postData.Length;
using (Stream writeStream = request.GetRequestStream())
{
UTF8Encoding encoding = new UTF8Encoding();
byte[] bytes = encoding.GetBytes(postData);
writeStream.Write(bytes, 0, bytes.Length);
}
}
var resp = request.GetResponse();
return cookie;
}