Richard,
Server.Transfer executes the page being requested without going back to the
client. It's a more direct, faster way to send a client a page. Here's a
comparison:
If a client requests page1 of your website and then posts back and you
execute a Response.Redirect to page2 the client browser is sent new code
that tells it to go to page2. Therefore in this scenario your handler gets
the correct page because the client has requested it.
If a client requests page1 of your web then posts back and you execute a
Server.Transfer to page2 the client browser is not contacted at all. Instead
the web server sends page2 to the client as if page2 is page1. The client
doesn't even know it's on a different page.
The context object is a common way to pass values from one page to another
when using Server.Transfer. Just before the transfer a value may be added to
the context object: Context.Item.Add("[Key]", [Value as Object]). Then on
the new page the same context object may be accessed via its key:
Context.Item("[Key]"). Perhaps you could set a context object when utilizing
Server.Transfer in order to set your template. I don't know for certain if a
context item will be accesible to your module... But it's worth a try.
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Richard" <ri*****@metavision.se> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
I've developed a small ASPX template framework (based on Chun Li's
article on CodeProject:
http://www.codeproject.com/aspnet/he...asp#xx849313xx) which
uses a IHttpModule to apply usercontrols (e.g. header and footer) on
pages.
The module determines if templates should be added to the page using
Page.Request.Path. It matches the current adress to settings found in a
configuration-file...
It works like a charm except for one little problem with
HttpServerUtility.Transfer.
Server.Transfer doesn't change the path-related properties needed.
I realize that the Path-property might not be the correct property to
use in this particular case.
The documentation states that the HttpRequest.CurrentExecutionFilePath
property should change when Server.Transfer is called.
I've verified that it does on the target/child page by outputting the
variable.
The problem lies in the fact that the property hasn't changed in the
IHttpModule.
I'm using the HttpApplication.Context which is of type
System.Web.UI.Page to attach an eventhandler to the Page.Init-event.
Is this a bug or am I missing something here!?
I want a non-intrusive way to add templates to any page. This means
that the page can't know anything about templates, such as utilizing
RewritePath which might avoid the problem.
Regards,
Richard