web.config - Invalid configuration data for the page? - asp.net

Created a Web Application in ASP.NET (c# language), than Build -> Published to Desktop, moved all files and folders to the ./test directory of the root of my localhost, than go to localhost/test/Default.aspx, and get this error message:
HTTP Error 500.19 - Internal Server Error The requested page cannot be
accessed because the related configuration data for the page is
invalid.
Points to this bit of code within web.config:
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
Actually, more digging reveals this:
There is a duplicate
'system.web.extensions/scripting/scriptResourceHandler' section
defined
Can I just define this in the root web.config file? Or is it safe to remove it altogether?

If this entry is defined in machine.config, then it's considered duplicate. Either remove this entry from web.config or add a remove sentence before.
<remove name="scriptResourceHandler/>

Related

ChartImg.axd error in ASP.NET 3.5.2

I am developing a webapp in ASP.NET framework 3.5.2.
After draging the Chart Control from the toolbox to where I want it in my .aspx page, there seems to be this added at the top of the document:
<%# Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
When I run I get the error: "Error executing child request for ChartImg.axd."
I have tried adding the following into system.web in my Web.config
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
</httpHandlers>
Then I get:
HTTP Error 500.23 - Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.
Most likely causes:
•This application defines configuration in the system.web/httpHandlers section.
It says that I can try to "Migrate the configuration to the system.webServer/handlers section".
How do I do this and how till it affect my webapp? Will something else stop working and is it possible to revert the migration?
With ASP.NET 3.5 projects where I got this error I went into IIS and changed the APplication Pool to run in Classic Managed Pipeline Mode rather than Integrated
To change this go to :IIS, go to Application Pools, Find the pool you're using and change it to Classic.

Avoid inherited ELMAH errors in an ASP.NET subapplication

I have a parent IIS application that uses ELMAH and a child ASP.NET application (virtual directory) that doesn't use ELMAH. When I try to browse my subapplication I get this error:
Could not load file or assembly 'Elmah' or one of its dependencies. The system cannot find the file specified.
Which is understandable as my child application's bin folder doesn't contain any ELMAH assemblies.
The problem probably is that the parent web.config file contains this:
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>
As far as I understand there is no way to stop <configSections> inheritance, see e.g. How to stop inheritance of <configSections>in Web.Config. Is there a way to run my ELMAH-free subapplication then?
You cannot keep your subapplication ELMAH-free because of the parent configuration. However - since I imagine you don't want to reference the assemblies from the parent - what you can do is tell your subapplication to look for assemblies in the parent bin folder with the probing configuration.
This way your subapplication doesn't need to know what assemblies exist for the parent, only that if an unknown assembly is needed it can be found in the parent folders
Edit: That's indeed a bummer. Clearing and removing configsections tags was considered too complex by Microsoft :
<clear /> and <remove /> were never implemented for configSections and sectionGroups because of the difficulty involved attempting to merge different definitions of the same section-handlers and section groups.
Hence the path workaround. You could also set up the applications so they are not related in terms of hierarchy, if this is critical
I have found that adding enableConfigurationOverride="false" to the application pool definition fixes this problem.
From the MSDN docs:
Optional Boolean attribute. When true, indicates that delegated settings in Web.config files will processed for applications within this application pool. When false, all settings in Web.config files will be ignored for this application pool.The default value is true.
There are two methods of doing this, where ChildApplicationName should be replaced with the value of your application pool name.
Method 1 (preferred/advised):
Execute the following command in appcmd in Administrator mode:
appcmd.exe set config -section:system.applicationHost/applicationPools /[name='ChildApplicationName'].enableConfigurationOverride:"False" /commit:apphost
Method 2:
The second involves directly editing the %windir%\System32\inetsrv\config\applicationHost.config file allows the application to effectively ignore the parent application. For various reasons, I don't advice doing this, but I leave this here for posterity.
In order to set this, do a search for your child application pool name. It should be under the xpath. /configuration/system.applicationHost/applicationPools.
<configuration>
<system.applicationHost>
<applicationPools>
...
<add name="ChildApplicationName" enableConfigurationOverride="false" />
...
<applicationPools>
<system.applicationHost>
<configuration>

I am getting this error when I run the web application

I am getting error when I run the application,
Could not load file or assembly
'System.Web.Extensions,
Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system
cannot find the file specified.
This is the error I am getting when I run the application, I added the new dll and increased the trust level. Can you help me please.
This you try to load on web.config on assembly session is too old (version 1)
Just remove the line from web.config and all is ok, you probably have the Extension again on assembly session from newer version net.
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Issue with Sitecore home page

Hi guys i am new to Sitecore and asp.net and iis.
I have installed all on my server 2008.
When i got to /localhost/sitecore/Website/sitecore.
I get following error. Can anyone help me what is this and what should i need to do.
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Source Error:
Line 2575: <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 2576: </httpHandlers>
Line 2577: <membership defaultProvider="sitecore"> -- this line shows errr
Line 2578: <providers>
Line 2579: <clear />
Seems like you have set up the site as a Virtual Directory in the IIS. Sitecore needs to run as a standalone site with its own application-pool. If you are using IIS6 and already have a site running on the default website you can use IISAdmin to add more sites http://iisadmin.codeplex.com/.
Hope this helps.

'System.Web.Extensions' trouble deploying .Net Framework 4 Website on IIS7

I am trying to deploy a .Net framework 4 website on IIS7 server. I have already changed the application-pool's target framework to .Net 4, but the app is still showing me the error:
"The configuration section 'system.web.extensions' cannot be read because it is missing a section declaration"
I am guessing that has something to do with the new feature of .Net4 that lets me have a compact Web config file. I think for some reason IIS7 is not happy with this.
What can I do to deploy this app successfully or do I have to scale back to v3.5? I am sure there is a solution out there.
Do you have any suggestions?
You can also get this very same error if you create a new website in IIS 7(.5) as the application pool it creates for the new site may still be set to 2.0, and as such, system.web.extensions is not valid in a 2.0 configuration file.
Simply go into IIS Manager, choose the application pools, select the one for your app, right-click, Advanced Settings and set .NET framework version to v4.
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x80070032
Config Error The configuration section 'system.web.extensions' cannot be read because it is missing a section declaration
Config File \\web.config
The error is due to this system.web.extensions section added to the Web.config
<system.web.extensions>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a custom converter
<jsonSerialization maxJsonLength="1024000">
-->
</webServices>
<scriptResourceHandler enableCompression="true" enableCaching="true"/>
</scripting>
</system.web.extensions>
For some reason adding that section, overrides the system.web.extensions group. The solution is to
Comment the code above if you don't need it.
Add the code below to the Web.config section group
..
<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>
I could solve this issue myself after some hunting around (happens!).
apparently has nothing to do with the way the config file is structured, it is the assembly for ASP.Net Ajax which is not deployed on my target server but might be present on my dev machine.
I deleted the entry from the web.config file and this issue was resolved, there were some other minor issues but nothing worth mentioning.
The deployment experience for IIS7+.Net Framework 4 wasn't too difficult and the added capabilities will going to be worth it.
I found the answer from Leo Tang post:
This issue not caused by the web.config migration. If you update you application to .Net Framework4.0, but assign this application to an application pool running under .Net Framework3.5 or previous version, you will encounter this error.
You can assign this application to an .Net Framework4.0 application pool in IIS to fix issue.
So, if you read the error The configuration section 'system.web.extensions' cannot be read because it is missing a section declaration it’s because the application you have deployed is running under an application pool configured to run under .NET 2.0 or 3.5 (DefaultAppPool? DefaultAppPool by default is set to .NET 2.0).
Perform the following steps:
Run IIS (exec 'inetmgr')
Select your application (probably 'Server\Sites\Default web site\Your application name' from the tree on the left panel)
Open your application settings (click 'Basic Settings' from 'Actions' the right panel) and look at the Application Pool.
Now choose the action that best fits your needs:
You can change the application pool for your application (button select in 'Application Edit' form, then choose 'ASP.NET v4-0 Classic'). This change will effect just this application
OR you can edit the application pool (probably Server\Application pools\DefaultAppPool rom the tree on the left) and set it to run under .NET Framevork v4.0 . Be careful: this change will effect every application under this Application Pool... is this what you want? maybe...
If "aspnet_regiis.exe -iru" don't help and you sure, that you try to launch site under .NET 4.0 App pool, it may be the problem in configuration inheritance of IIS 7.0. Web server reads machine.config of .NET 2.0.
Applying of hotfix KB958854 would solve the problem with configuration inheritance. I have successfully fixed my problem in this way.
It’s because you’ve deployed your application on to an IIS Server where the application’s AppPool is set to run under the DefaultAppPool. DefaultAppPool is automatically configured to run under .NET 2.0 rather than .NET 4.0. This means that the System.Web.Extensions stuff is unavailable to that version of the .NET Framework.
To change the Application Pool (AppPool) settings for your web application
1. Select the application directory
2. Under Actions, click Basic Settings…
3. Change the Application Pool to ASP.NET v4.0 (or another .NET 4.0 app pool) by clicking on the Select… button.
4. Click OK
Re-run your application and it should work.
Check this link for graphical demonstration.
I solved the issue by following below steps:
1. set application pool framework to 4.0
2. if point 1 wont work, then problem could be related to config inheritance.
Apply hotfix from http://support.microsoft.com/kb/958854
This should solve the issue.

Resources