Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making an OEM skinned version of our ASP.NET site for a customer. I need to make a subfolder in the current architecture look like our main site, except that the pages are re-skinned with different images.

The web site uses one master page to do the layout, so I figure that I can handle all the skinning there, if I could redirect all requests to the subfolder to its corresponding page in the main hierarchy. Then the master page code-behind can check the original URL and adjust images accordingly.

Like so:

http://my.website.com/OEM/page.aspx

would be exactly like

http://my.website.com/page.aspx

but with different images.

What I have tried:

I created a Default.aspx in the subfolder, and in the code-behind I call Server.Transfer(). This seems to work for the main page, but I get Error 404 when I try to access any other pages.

Now I am far too lazy to make a file for every page on the web site, so I wonder if there is a way to configure the folder to funnel every request to /OEM/* to /OEM/Default.aspx, or even to have all requests automatically transferred to a different folder.

Note that I would not like to use HTTP redirects; the transfer should happen in the server side only.
Posted
Updated 9-Sep-16 4:56am
Comments
Mehdi Gholam 9-Sep-16 10:11am    
Why not create a new domain (i.e. http://oem.website.com) to another folder with the changed site?

1 solution

Sounds like you need the URL Rewrite[^] module.
XML
<system.webServer>
    <rewrite>
        <rules>
            <rule name="Site Skin">
                <match url="^(OEM)/([^?]*)(.*)$" />
                <action type="Rewrite" url="{R:2}?_skin={R:1}" appendQueryString="true" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

This will redirect oem/anyPage.aspx?query to anyPage.aspx?_skin=oem&query; you can then use the _skin query-string variable to decide which skin to use.

Extending it to other folders is as simple as adding another value to the <match> element:
XML
<match url="^(OEM|OEM2|Another)/([^?]*)(.*)$" />
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900