Page view counter

URL Rewriting with Rewrite Path - Relative links Problem

Last post 10-15-2008 9:56 AM by Andyh321. 1 replies.

Sort Posts:

  • URL Rewriting with Rewrite Path - Relative links Problem

    10-15-2008, 8:24 AM
    • Loading...
    • Andyh321
    • Joined on 04-26-2007, 10:20 AM
    • Posts 3
    • Points 2

    Hi all

    Not sure if this is the best category to post this, but hey, worth a try!

    I have a new project in VS2008, in which I catch the requested path in Application_BeginRequest and send the user on to the relevant page.

    This works fine.

    However, I am having problems with page references etc.

    For example, if i want my internal page links to work, i.e. href="category/product1/", then I need a base tag.
    When i have a base tag, my css links are lost - so if i was on the page http://www.mysite.com/category/product1/, then the css link will be ../../stylesheet.css. This obviously does not work.

    I can get the css to work by importing the css instead, but that still leaves a problem with my form's action attribute - it will be looking for ../../Product.aspx?ProductID=1.

    I can also solve this problem by overriding the forms attribute.

    I am still left with dynamic image urls (in the code behind) being relative to the main route!

    However, I can solve all of these problems should I wish, BUT, my colleague who has exact same code but is using VS2005, can get his to work!!!! i.e. there is no ../../ before his css link for example!

    This is very frustrating!

    Does anyone have any ideas why - is it a difference in my VS settings, or is my IIS different?

    Just so you know, my VS solution has multiple projects - a couple of class libraries plus a couple of websites, and I have some virtual folders for images etc.

    The web app I am talking about has one Master page which is used in all cases.

    Any advice would be much appreciated!

    Kind regards

    Andy

  • Re: URL Rewriting with Rewrite Path - Relative links Problem

    10-15-2008, 9:56 AM
    Answer
    • Loading...
    • Andyh321
    • Joined on 04-26-2007, 10:20 AM
    • Posts 3
    • Points 2

     Hi all

    just thought I would let you know that I have the solution!!!

    The following:

    HttpContext.Current.RewritePath("~/SomePage.aspx",false);

    should be

    HttpContext.Current.RewritePath("~/SomePage.aspx",true);

    in Application_BeginRequest.

    I wish i had spotted that sooner!

    Cheers

    Andy

     

Page 1 of 1 (2 items)