« Previous Next »

Thread: Rewrite rule is affecting virtual application root for all asp.net controls

Last post 09-29-2009 9:41 AM by McDotNet. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 09-25-2009, 10:04 AM

    • McDotNet
    • Not Ranked
    • Joined on 09-10-2008, 12:41 PM
    • Posts 8

    Rewrite rule is affecting virtual application root for all asp.net controls

    Hi i am using the following rule to map a domain through to a subfolder in my shared hosting environment:

    <rule name="mydomain.co.uk">
    <
    match url="(.*)" />
    <
    conditions logicalGrouping="MatchAny">
    <
    add input="{HTTP_HOST}" pattern="^www.mydomain.co.uk$" />
    <add input="{HTTP_HOST}" pattern="^www.mydomain.com$" />
    <add input="{HTTP_HOST}" pattern="^mydomain.co.uk$" />
    <
    add input="{HTTP_HOST}" pattern="^mydomain.com$" />
    </conditions>
    <
    action type="Rewrite" url="MyDomainFolder/{PATH_INFO}" />
    </rule>

    This rule allows me to access my website at www.mydomain.co.uk instead of www.mydomain.co.uk/MyDomainFolder/.

    The problem is the rule changes the virtual root of my application. A control with a href="PageTwo.aspx" becomes href="MyDomainFolder/PageTwo.aspx" this also the same when using the tilde: href="~/PageTwo.aspx" becomes href="MyDomainFolder/PageTwo.aspx"

    Is there a work around for this as all the links in my application become broken?

    I have also found that response.redirects do not work at all.

  • 09-28-2009, 8:06 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 3:38 PM
    • Redmond, WA
    • Posts 661

    Re: Rewrite rule is affecting virtual application root for all asp.net controls

    What version of .net framework do you have? The URL rewrite module includes an ASP.NET QFE that will cause the URL's with "~" to be resolved relative to the originally requested URL, not the rewritten one. The QFE is only applied if you have .NET Framework 3.5 SP1 or later installed. (see more information here http://learn.iis.net/page.aspx/517/url-rewriting-for-aspnet-web-forms/)

    http://ruslany.net
  • 09-29-2009, 9:41 AM In reply to

    • McDotNet
    • Not Ranked
    • Joined on 09-10-2008, 12:41 PM
    • Posts 8

    Re: Rewrite rule is affecting virtual application root for all asp.net controls

    Yes the webserver is running .NET Framework 3.5 sp1 and the web application is setup for .NET framework 3.5.

    Would I need to change anything in my web.config for service pack 1?

    The strangest problem is Response.Redirect which won't even redirect to an external url it always redirects to: Requested URL: /MyDomainFolder/MyDomainFolder/CurrentPageName.aspx

     The most common thing I am noticing when the paths incorrect is that it is doubling the folder name in the paths to  /MyDomainFolder/MyDomainFolder/

     Any help will be greatly appreciated!!

    Thanks

     

     

Page 1 of 1 (3 items)
Microsoft Communities