You Don’t Always Need Page Modules

From my article on Page Modules some people might have gotten the wrong impression that this would be the only way to get a reference to the page given its path, but it isn’t.

You can use the System.Web.UI.PageParser.GetCompiledPageInstance method to get the reference to the page before calling the System.Web.HttpServerUtility.Transfer method.

There’s one caveat, though. Unlike the version of the System.Web.HttpServerUtility.Transfer method where you that takes a virtual path as an argument, this one will not change the values of the System.Web.HttpRequest.AppRelativeCurrentExecutionFilePath and System.Web.HttpRequest.CurrentExecutionFilePath properties won’t change from the original request.

That can either be a problem or the solution to a problem.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>