Hi everyone, I have a web method in second.aspx,which has to be executed only if the incoming request is 'application/json'.So in my First.aspx page I am programmatically generating a Http request with content type set to 'application/json' using the following code.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://localhost/website1/Second.aspx");
req.ContentType = "application/json";
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
string results = sr.ReadToEnd();
sr.Close();
and in the Second.aspx i am checking the incoming request in javascript using <%= Request.ContentType %>
to see if it is 'application/json'.If yes I want to execute the web method using jquery ajax method.If I write the streamreader 'sr' to a textbox I can see that <%= Request.ContentType %>
gives 'application/json'.But my problem is the HTML of Second.aspx is loaded into the textbox on First.aspx but no redirection to Second.aspx is taking place.so I am unable to exceute the web method this way.
Please could someone help me how do I rediret to Second.aspx page with the above programmatically generated HTTP request code?