PC Review


Reply
Thread Tools Rate Thread

Context.RewritePath and master pages

 
 
Keef
Guest
Posts: n/a
 
      14th Oct 2008
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

 
Reply With Quote
 
 
 
 
Göran Andersson
Guest
Posts: n/a
 
      14th Oct 2008
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
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get User Context in Master Pages Matt Microsoft ASP .NET 1 25th Sep 2006 08:56 PM
Context.ReWritePath Critical Bug Oytun YILMAZ Microsoft ASP .NET 1 16th Oct 2004 07:21 PM
Re: Context.RewritePath not working in NN4 Microsoft ASP .NET 0 22nd May 2004 09:36 AM
Context.RewritePath Ayende Rahien Microsoft ASP .NET 0 16th Jan 2004 11:55 PM
Context.Rewritepath following Querystring access Matt Howeson Microsoft ASP .NET 0 18th Nov 2003 02:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:29 PM.