Context.RewritePath and master pages

  • Thread starter Thread starter Keef
  • Start date Start date
K

Keef

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
 
Keef said:
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.
 
Back
Top