0

I have a Request which I make to a page and works fine. I can also view that page the response page with Fiddler.

But how do I open this response in my browser?

Currently what I have:

            Cookie cookie = new Cookie("test","this");
            cookie.Domain = "foobar";


            HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create("http://foobar/ReportServer/");
            request.CookieContainer = new CookieContainer();
            request.CookieContainer.Add(cookie);

            WebResponse response = request.GetResponse();
            Stream sr = response.GetResponseStream();
            StreamReader sre = new StreamReader(sr);
            string s = sre.ReadToEnd();
            Response.Write(s);
Hillboy
  • 472
  • 6
  • 19
  • Please explain what you mean by "open this response in my browser". – CodeCaster Nov 14 '14 at 16:12
  • @CodeCaster For instance there is Response.Redirect(URI). I want to do this same functionality but i already have my request and response and would just wish to open up this response in the browser. Right now what I'm doing which works is doing a request which saves info related to the user on the other site foobar then I redirect them like Response.Redirect(url), creating what seems like to me a redundant thing to do. – Hillboy Nov 14 '14 at 16:15

3 Answers3

1

Save it to an HTML file and open the browser with the path to that file.

Community
  • 1
  • 1
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • I like this idea. But the Response is from another asp.net page. I don't think html will behave properly. Since usually when you attempt to save a .aspx page in html it doesn't work – Hillboy Nov 14 '14 at 16:12
  • It's very unclear what you want this code to do then. When does this code run? Why doesn't `Response.Write(s);` do what you want it to? – CodeCaster Nov 14 '14 at 16:12
  • When I do Response.Write(s) which I thought would be the solution it does nothing. Even when I look at fiddler, nothing. The code runs off a button click on a web page on domain 'foo' the request is to page 'foobar'. – Hillboy Nov 14 '14 at 16:34
0

Because you have addressibility to the request "Stream" you can use this method: NavigateToStream : http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.navigatetostream(v=vs.100).aspx

  this.webBrowser.NavigateToStream(sr);
JWP
  • 6,672
  • 3
  • 50
  • 74
-1

You can use System.Windows.Forms.WebBrowser control.

Farzan Hajian
  • 1,799
  • 17
  • 27