Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
Using WebRequest to get the rendered HTML of protected page, returns login page
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Rick Strahl [MVP], post: 358566"] Hi Stephen, Is the Report and ASPX page in the same application? If so you might want to look into just calling Server.Execute() to execute the page which allows you to run the page and pass in your own HTMLTextWriter() and then retrieve the result. Something like this: public static string AspTextMerge(string TemplatePageAndQueryString,ref string ErrorMessage) { string MergedText = ""; // *** Save the current request information HttpContext Context = HttpContext.Current; // *** Fix up the path to point at the templates directory TemplatePageAndQueryString = Context.Request.ApplicationPath + "/templates/" + TemplatePageAndQueryString; // *** Now call the other page and load into StringWriter StringWriter sw = new StringWriter(); try { Context.Server.Execute(TemplatePageAndQueryString,sw); MergedText = sw.ToString(); } catch { MergedText = null; } return MergedText; } FWIW, using an HTTP request is not much slower in this situation - the above code also requires a fair amount of overhead as ASP.Net has to perform some fixup to 'fake' this request through Execute. I've used HTTP in a number of situations with good results - your only concern will be not tying up the ASP.Net thread for too long waiting for the report to finish - if that's the case you may have to do this asynchronously... +++ Rick --- -- Rick Strahl West Wind Technologies [URL]http://www.west-wind.com/[/URL] [URL]http://www.west-wind.com/weblog/[/URL] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
Using WebRequest to get the rendered HTML of protected page, returns login page
Top