How do you isolate a subapplication from the main site on IIS7 - asp.net

Senario:
I'm running IIS7 on Win Server 2008 Web Edition
I have a MVC application at the route of the website (main app)
The website HOST is domain.com
I've created a virtual application /testapp with has an ASP.Net application (sub app)
Problem:
when I navigate to http://domain.com the main app works as expected but when I navigate to http://domain.com/testapp the sub app seems to be running but processing the main app web.config.
Some of the errors I was getting involved missing dlls that only the main app required - this could be solved by copying the dlls into the sub app bin folder but isn't an ideal solution.
Question:
I don't think this is an MVC/ASP.Net issue but instead an ISS7 one. How do I configure IIS7 so that these two application don't interfere with each other?

This problem is by design due to inheritance of web.config files. You have a couple of solutions:
Move the site elements at the root of the site into a application subfolder that sits side by side with your other application and remove as much of the parent's web.config as possible.
Copy all the elements in the parent web.config to the child web.config that are needed and use the location elements to block inheritance in the child:
< location path="." inheritInChildApplications="false" >
< system.web >
...
</ system.web >
</ location >

I had similar problem when I've add custom modules in my ASP MVC 4 application running on IIS7.
I've found a solution by simply removing and adding the module as so:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="GlobalizationModule"/>
<add name="GlobalizationModule" type="GlobalizationHttpModule, MyWebSite"/>
</modules>
</system.webServer>
It is specific solution to this problem, hope it helps.
Ido.

Related

Stop bad handler mappings from re-appearing

I'm on Windows 10 running an ASP.Net web app locally in IIS Express. Initially when I was trying to serve my app on localhost I introduced some bad handler mappings in my IIS Express options for the app. I figured out I didn't have IIS ASP.Net installed as part of IIS and fixed that. Then I removed the bad mappings and everything works. But every time I restart my app in IIS the bad mappings re-appear, and I have to remove them again. How do I permanently delete or remove these bad mappings? Thanks in advance for any replies.
I think I figured it out. I added lines to remove the bad handlers in my Web.cong in the system.webServer section ( the Web.config in my projects root folder). The problem was happing everytime I published to the local server. Seems intorducing these lines replaces the Web.config in the app's root folder for the server. Adding these lines seems to fix the problem. Here's the lines I added:
<handlers>
<remove name="Start Module" />
<remove name="Start" />
</handlers>

Aurelia does not load on azure, due to HttpPlatformHandler?

I'm using ASP.NET Core RC1 as server to host my Aurelia app. My app was working just fine but the last couple of weeks something changed so that the app does no longer load when hosted on Azure. I'm not sure if it is something I changed or if it's a change on the Azure side but I'm leaning towards the latter.
I've narrowed down the problem quite a bit. The app runs fine locally, with ASP.NET Core Kestrel server and also other servers (e.g. webpack-dev-server). I have continuous deployment setup from Visual Studio Team Services to an Azure Website. The app is published and a web.config is automatically created in my wwwroot:
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%home%\site\approot\web.cmd" arguments="" stdoutLogEnabled="true" stdoutLogFile="\\?\%home%\LogFiles\stdout.log"></httpPlatform>
</system.webServer>
</configuration>
Nothing happens when I navigate to my site, e.g. http://demo.azurewebsites.net/. When looking at the console I get a 404. Once I actually got this error but I can't seem to bring it back: 502 - Web server received an invalid response while acting as a gateway or proxy server
I have index.html set as default document but it is not loading. If I enter it explicitly, the app works: http://demo.azurewebsites.net/index.html
If I remove the httpplatformhandler from the web.config, then it works as expected (index.html is loaded automatically). The same happens when I remove the web.config entirely. In these cases the MVC 6 WebAPI behind the scenes does not work at all. I assume that's just logical since I remove the platform handler.
So, why is this httpplatformhandler added? Is it necessary? Why is it created? Is there some setting in the Azure portal that I can adjust to prevent this handler to be configured like this?
I also found this link that seems to suggest that things are changing and that this httpplatformhandler is about to be replaced: Closer Look: Hosting ASP.NET Core on Azure App Service
I'm out on deep water here and any and all help is appreciated.
To get default document support with the static file server middleware you need to use app.UseFileServer() instead of app.UseStaticFiles()

How to set Allow Parent Paths in IIS Express Config using asp directive

This is a continuation of a answered question in the following link:
How to set Allow Parent Paths in IIS Express Config
I am running a classic asp web site in IISexpress.
The same web site is also used in IIS 7.5 in a w7 pro and works fine enabling the parent paths in the IIS configuration of the web but trying to use the web.config in IISExpress does not work
The problem that I am experiencing is that in the suggested web.config in order to enable the parent paths:
<configuration>
<system.webServer>
<asp
enableParentPaths="true"
bufferingOn="true"
errorsToNTLog="true"
appAllowDebugging="true"
appAllowClientDebug="true"
scriptErrorSentToBrowser="true">
<session allowSessionState="true" />
<cache diskTemplateCacheDirectory="%TEMP%\iisexpress\ASP Compiled Templates" />
<limits />
</asp>
</system.webServer>
</configuration>
I get a 500 error every time that I try to use any asp tag
If I remove the asp tag it all works fine,
Anybody has a clue?
TIA
You have not read carefully. The configuration file that mentioned isn't web.config. It is applicationHost.config. As a shotcut:
Press Win+R
type
notepad "%userprofile%\Documents\IISExpress\config\applicationhost.config"
hit ⏎. This will open the host configuration file with notepad. You need to find your web site's section. It's something like <location path="YourSiteName"> ... </location>. Look inside that node, find the <asp> section and change with yours. Finally, don't forget to remove the asp section from web.config.

Migrate ASP from root to subdirectory

I'm in the process of converting an existing ASP website into PHP while retaining the ASP website as an older version. Since I'm not an ASP developer, I thought it would be simple as moving the contents of the root directory into its own directory that I've labeled as v1.0 so that the ASP version can be viewed by going to www.mysite.com/v1.0 while the new PHP version (v2.0) can be viewed by going to www.mysite.com
Herein lies the problem. Doing this causes flags all kinds of errors (all related to "Server Error in '/' Application. Runtime errors"). The best I can figure out is that the web.config file needs to be tweaked in the v2.0 directory. Can any of you ASP experts recommend a simple solution to make this happen? I would like to have an empty root directory if possible since the new v2.0 version will be in all PHP and want to "self contain" the ASP version within the v1.0 directory as much as possible.
Thanks!
After a bit of wrangling, finally figured out that I needed to set up v1.0 as its own application under the IIS control panel. Once that was done, then all the contents of the root directory could be moved over to the v1.0 sub-directory and viewed via www.mysite.com/v1.0 -- thanks to Sean! for his help!
Most Classic ASP pages use Server Side Includes, if the site is using a SSI such as:
<!-- #include virtual = "include-file.inc" -->
, then you will need to change all of these to be
<!-- #include virtual = "v1.0/include-file.inc" -->.
I assume that you are using IIS 7 or IIS 7.5, since you are not seeing the actual error, you will need to modify your web.config file.
<configuration>
<system.webServer>
<asp scriptErrorSentToBrowser="true" />
<httpErrors errorMode="Detailed">
</system.webServer>
</configuration>
Reference:
http://learn.iis.net/page.aspx/564/classic-asp-script-error-messages-no-longer-shown-in-web-browser-by-default/
Update
Since it now sounds like you are using ASP.NET, you would need to change your web.config as below to see the full error:
<configuration>
<system.web>
<customErrors mode="Off" />
</system.web>
</configuration>

IIS7: disabling HttpModule in subapplication - sites, application and virtual directories

I have a few aspx files in a "Cache" folder in my application and I do not want HttpModules to run for those files in that folder. I tried having a web.config in subdirectory but learned that HttpModules take the root web.config and not that of the subdirectory.
Reference 1, Reference2. So I decided to have this directory as a sub application as per suggestion here and here.
So I configure my application,then "add application" , map it to this directory, which already was inside this application and boom, it fails. It works for a static html file, but aspx files are not available.
My question is, how do I configure a sub-application in IIS7 so that the sub-application can have its own web.config and there I can disable HTTPModules of the root application
Edit:In fact I tried creating a subapplication within my main application and it did not work. Can some one point me to any article on how to configure a sub-application in IIS7 ?
Edit2: adding the error image. So how should I configure the child app pool. The child app runs in the same app pool as that of parent
Edit3: sorry, the child was running on a different app pool. A generic app worked(without modules). I am marking the answer after I try out the modules.Thanks for your help guys. There is something specific in my parent app web.config, which I am going to hunt down now.
EDIT: Actually both the answers provided below are correct. If you are using IIS7 integrated mode your modules should be in system.webServer and if IIS7 - classic mode your modules (and handlers?) should be in system.web
JKG has the right answer for IIS6, but the syntax is a little different in IIS7:
<system.webServer>
<modules>
<remove name="MyModule"/>
</modules>
</system.webServer>
The web.config will always inherit from its parent if it's in the same web application but you can clear the entire thing or remove an item like so:
From the child web.config (clear all or remove an item)
<httpModules>
<clear />
<remove name="MyModule"/>
</httpModules>
From the parent config by using the location tag...
<location inheritInChildApplications="false">
<system.web>
<!-- ... -->
</system.web>
</location>
http://www.jaylee.org/post/2008/03/Prevent-ASPNET-webconfig-inheritance-and-inheritInChildApplications-attribute.aspx

Resources