views:

588

answers:

4

Is there a way of running an ASP.NET website in a subfolder of the website?

As an example, say I wanted to run the screwturn wiki (http://www.screwturn.eu/) in a folder called "wiki" on my website, can I alter the web.config of the screwturn website to tell it that it is running in the "wiki" folder? (like saying that "~/" = "/wiki/")

The wiki would then find its assemblies that are in "~/bin" in "/wiki/bin" and the same for all other folders below the new root.

A: 

Short answer is YES you can. No need to specify the location of the folder in the Web.Config.

o.k.w
I am assumming you have a web.config in the wiki folder. "/wiki/bin" is automatically located by the runtime.
o.k.w
But the pages fail to load, claiming that "The file '/MasterPage.master' does not exist.". The aspx page directive has MasterPageFile="~/MasterPage.master". The question is how I make that resove to "/wiki/MasterPage.master" rather than "/MasterPage.master".
Bernhard Hofmann
Is the "wiki" folder configured as an Application in IIS?
o.k.w
No, it's just a folder under the main application folder which is running it's own website.
Bernhard Hofmann
Will "wiki" be an independent app? If so, set the folder as an application. This will isolate the folder from the parent folder.
o.k.w
+2  A: 

Piece of cake, you can either add a virtual directory to the root of the IIS website and point it at the path of your site or place it an a physical directory in the website root then turn it into an application by right-clicking on it in the IIS management console, going to properties and clicking "Create" next to application name.

Troy Hunt
Although I didn't mention it, I do not have control of the web server. But this is the nearest to the solution I took, which was to create a subdomain (wiki.mydomainname.org). I'll mark this as the answer because your suggestions are on the mark had I had access to IIS on the ISPs box.
Bernhard Hofmann
A: 

I had to do this recently, and having made the wiki folder an application (as suggested in the previous answers) I also had to place a dummy 'App_Themes -> Default' folder at the top-level within the Wiki app because of the presence of the <pages styleSheetTheme="default" theme="default"> tag in the parent app's Web.config. Small hack, but that's the way I like to configure my styles in Asp.Net, and I didn't want to change that.

Rafe Lavelle
A: 

You need to stop the configuration inheritance in the root web.config file so that the wiki web.config doesn't read anything from the root web.config.

Details here

Tony_Henrich