How to create a virtual folder (subweb) under root web site with out errors

This post is related to IIS server and ASP.NET. Before start steps to create. I want to talk about “sub web site under root web site”.

IIS server and asp.net web sites : Share Our Ideas

For example :-

We created one asp.net web site using  own code/CMS. So, for some functionality  we planned to use some other asp.net CMS/ our custom code sites. So, we can create those sites under root web site. This we can get easily  by creating virtual directory under root web site. But the problem is, we will get some error when we run sub web site. Like which I listed  here

Server Application Unavailable

Configuration Error (and points to httpHandlers and httpModules)

this above error will get when root web site and sub web site is developed in asp.net same/different versions.

Solution  for Server Application Unavailable error :-

Sometimes we will get this error, when we create new web site under root web site/ virtual directory.

we can come over this by follow few steps while creating time. we have to make sure created virtual directory/web site create like application. else we can make it . Please look at this URL for more details http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q301/3/92.asp&NoWebContent=1

Solution for Configuration Error :-

Virtual Directory looking at parent web.config settings by default. we need to stop that to over come from this issue. for this we need add <remove> element in <httpHandlers> and <httpmodules>
inside of sub-website web.config file, get more details here http://msdn.microsoft.com/en-us/library/e0dzxdza%28v=vs.71%29.aspx and http://msdn.microsoft.com/en-us/library/81b3ekbd.aspx we have remove root web site handlers and modules in sub web site’s web.config. So, it will start works with issues.

But, some times we will get error at <pages> in root web.config. we can’t do same like above. I mean we can use <remove> element here.

for this we need to take advantage of <location> element. if we add location we no need to user remove elements inside handlers and modules.

About Location element

Specifies the resource that child configuration settings apply to and locks configuration settings, preventing the settings from being overridden by child configuration files. get more details here.

here is the final solution :-

<location path=”.” inheritInChildApplications=”false”>
<system.web>
<httpHandlers …………..

<httpmodules ……………

<pages…………..

…..

</system.web>
</location>

This works prefect, because root web site settings will not apply to child applications.

Thanks,

Naga Harish.

Leave a Reply