Run an ASP.NET website in a subfolder
Solution 1
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.
Solution 2
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.
Solution 3
As others pointed out. basically you need to put this in your child application Web.config, of course you also need to configure the domain (sub domain etc.), IIS setting as well.
<configuration>
<location path="." inheritInChildApplications="false">
//your code here
<system.web>
//your code here
</system.web>
//your code here
</location>
</configuration>
Comments
-
Bernhard Hofmann almost 2 years
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.
-
o.k.w over 14 yearsI am assumming you have a web.config in the wiki folder. "/wiki/bin" is automatically located by the runtime.
-
Bernhard Hofmann over 14 yearsBut 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".
-
o.k.w over 14 yearsIs the "wiki" folder configured as an Application in IIS?
-
Bernhard Hofmann over 14 yearsNo, it's just a folder under the main application folder which is running it's own website.
-
o.k.w over 14 yearsWill "wiki" be an independent app? If so, set the folder as an application. This will isolate the folder from the parent folder.
-
Bernhard Hofmann over 14 yearsAlthough 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.
-
James almost 13 yearsI tired this but now IIS is complaining that in cant find the code behind class for the login page. Do sub sites inherit the same dlls as the parent? Because the login in page class for the sub site is compiled into the main sites dll as its all the same project in VS.
-
Troy Hunt almost 13 yearsYou need an entire, self-contained app in the folder otherwise it will be looking for a bin directory which doesn't exist.
-
Fuchida almost 10 yearsThe live site for the link above is dead. The cached copy can be found here
-
Jonas Äppelgran over 8 yearsIf you have
<configSection>'s
in your web.config, those should be outside the<location>
tag. -
Muhammad Adeel Zahid over 8 yearsWhat if someone does not have access to IIS settings? I don't have access to the web.config of root application. Is there a way to make a web application in sub directory
-
Adam Baxter about 8 yearsCached copy has been pulled due to archive.org's robots.txt policy.
-
VDWWD almost 7 years