On attempting to deploy a .net 3.5 website on the default app pool in IIS7 having the framework section set to 4.0, I get the following error.
There i
Necromancing.
If you don't have any system.web.extensions config-sections or handler/module entries in your web.config, this problem is caused because you/somebody else copied a VisualStudio-Project (2013/2015/2017) while having hidden-files unhidden.
Because of that, it will not only copy .git, but also .VS
, which contains an IIS-Express applicationhost.config file, which points to web.config files at paths that don't exist (or worse, paths that do exist, but do not have the same content)...
Solution:
Delete the applicationhost.config file in the .VS folder.
Or just delete the .VS folder altogether.
Visual Studio will re-create it.
In my case I wanted to manually add urlrewrite rule and couldn't see the obvious error (I missed <rules>
tag):
wrong code:
<rewrite>
<rule name="some rule" stopProcessing="true">
<match url="some-pattenr/(.*)" />
<action type="Redirect" url="/some-ne-pattenr/{R:1}" />
</rule>
</rewrite>
</system.webServer>
</configuration>
proper code (with rules tag):
<rewrite>
<rules>
<rule name="some rule" stopProcessing="true">
<match url="some-pattenr/(.*)" />
<action type="Redirect" url="/some-ne-pattenr/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
This error message seems to come up in various situations.
In my case, on top of my application's Web.Config file I had an extra Web.Config file in the root folder (C:\Inetpub\www.root). Probably left there after some testing, I had forgotten all about it, and couldn't figure out what the problem was.
Removing it solved the problem for me.
My app was an ASP.Net3.5 app (using version 2 of the framework). When ASP.Net3.5 apps got created Visual Studio automatically added scriptResourceHandler to the web.config. Later versions of .Net put this into the machine.config. If you run your ASP.Net 3.5 app using the version 4 app pool (depending on install order this is the default app pool), you will get this error.
When I moved to using the version 2.0 app pool. The error went away. I then had to deal with the error when serving WCF .svc :
HTTP Error 404.17 - Not Found The requested content appears to be script and will not be served by the static file handler
After some investigation, it seems that I needed to register the WCF handler. using the following steps:
My resolution was kind of stupid.
I installed a copy of .net 3.5
Created another app pool and selected .net 3.5 (it says 2.0.5077 in the drop down)
Added my website to that app pool
Recycled the old and new pools and the site started working.
It came down to me not having 3.5 installed even though the turn on windows features said I did and creating another app pool to use. I hope this helps others.
If, like me, you need to target v4 but can only build with .net 3.5, follow the instruction here. Just replace in your web.config the whole content of the <configSections>
with:
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>