By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,971 Members | 1,451 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,971 IT Pros & Developers. It's quick & easy.

Context.RewritePath and master pages

P: n/a
Hiya...

just wondering if anyone else has come across this problem, and if there is
a solution...

i'm writing a reasonably simple IHttpModule to rewrite URLs ...

in the BeginRequest event i do a app.Context.RewritePath("~/"+theFile,false)
to the aspx file to display the content, then in the
PreRequestHandlerExecute i do another RewritePath so that all the relative
links (css, images, postabcks, ajax etc..) find thier correct locations...

this works fine, as long as the aspx page is not inside a master page...

when the aspx page uses a master page, the RewritePath only fixes the
relative links contained in the master page and all the relative paths in
the content page don't change!!

is this a bug? or am i missing something?

any help is much appreciated..

thanks k

Oct 14 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Keef wrote:
Hiya...

just wondering if anyone else has come across this problem, and if there
is a solution...

i'm writing a reasonably simple IHttpModule to rewrite URLs ...

in the BeginRequest event i do a
app.Context.RewritePath("~/"+theFile,false) to the aspx file to display
the content, then in the PreRequestHandlerExecute i do another
RewritePath so that all the relative links (css, images, postabcks, ajax
etc..) find thier correct locations...

this works fine, as long as the aspx page is not inside a master page...

when the aspx page uses a master page, the RewritePath only fixes the
relative links contained in the master page and all the relative paths
in the content page don't change!!

is this a bug? or am i missing something?

any help is much appreciated..

thanks k
The RewritePath doesn't change any links at all, neither in the master
page nor the content page. It changes the requests, and those are the
same regardless if they come from code that was generated by the master
page or the content page. The browser doesn't even know the difference.

I think that your problem is that the URLs that you put in your code is
resolved from the path of the source file instead of the path that is
used to request the page.

I recently deployed URL rewriting on a site, and that involves a
completely different way of handling the URLs in the site. The built-in
methods in ASP.NET for resolving URLs are totally thrown off, and you
have to take complete control over how the URLs are created. I even had
to add code to change the URL that is placed in the action property of
the form tag, because ASP.NET can't even make a postback any more.

--
Göran Andersson
_____
http://www.guffa.com
Oct 14 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.