Output aspx from ashx
-
Hi, lets say I have a folder called dogs on my server. Now theres a bunch of different aspx pages in there, and certain users are only allowed to access certain ones(note:each aspx page cannot do its own authentication). Now when someones goes to server/dogs/page3.aspx im going to use url rewriting to send them to my ashx page. The ashx page will then check the logged in users session, see if he has access to the page he tried to see and then output the resulting page. I have this working fine on a previous project out putting images. But now im worried that outputting it a similair way will "break" the link between the aspx page and its code behind. So whats the best way to go about this? Thanks so much :)
Strive to be humble enough to take advice, and confident enough to do something about it.
-
Hi, lets say I have a folder called dogs on my server. Now theres a bunch of different aspx pages in there, and certain users are only allowed to access certain ones(note:each aspx page cannot do its own authentication). Now when someones goes to server/dogs/page3.aspx im going to use url rewriting to send them to my ashx page. The ashx page will then check the logged in users session, see if he has access to the page he tried to see and then output the resulting page. I have this working fine on a previous project out putting images. But now im worried that outputting it a similair way will "break" the link between the aspx page and its code behind. So whats the best way to go about this? Thanks so much :)
Strive to be humble enough to take advice, and confident enough to do something about it.
Found a solution from a combination of 2 articles. Heres the code inside ProcessRequest: string page = "~/Dogs/Page3.aspx"; Page compiledPage = (Page)PageParser.GetCompiledPageInstance(page, context.Server.MapPath(page), context); compiledPage.ProcessRequest(context);
Strive to be humble enough to take advice, and confident enough to do something about it.