Wednesday 15 April 2015

c# - Can you make a server side httprequest that mimicks a html form post? -


When you do an HTML POST on a page, it does this:

    < Li> Valid
  1. Redirects the user to a different URL and responds to an authentication cookie and other cookies.

    If I create a simple HTML page with a form, it works fine and I get redirected.

    Is it possible to do this only on server side? If the last point reads the form field, and then redirects to the cookies, then I do not feel right because there will be no idea of ​​cookies in the server side?

    WebRequest.Create (your_url); Request method = "post"; Request.ContentType = "application / x-www-form-encoded"; StreamWriter SW = new streamer (request.GetRequestStream); // '// Response WebRepass Wr = Request Request GetResponse; StreamRider sr = New Streamminder (wr.GetResponseStream); Var Return Valve = SR.ReadToEnd.Trim;

    You can set cookies on posts like this :

      request.Headers (HttpRequest Header.Cookie) = "MyCookie = value;";    

    No comments:

    Post a Comment