This configuration section cannot be used at this path - Windows 2016 - iis-10

Getting below error after migrating MVC application to Windows 2016.
Roles & features look good to me,
Roles & Features
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Any solution?

This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
As far as I know, this error means the config section is locked by the some other config.
Normally, the error message page's “config source” part will contain which section has been locked.
Then you could go to “C:\Windows\System32\inetsrv\config” (you will need administrator rights here) Open applicationHost.config to change the overrideModeDefault attribute from deny to Allow.
For example:
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />

1. Edit this file “C:\Windows\System32\inetsrv\config\applicationHost.config”
2. Replace this line:
<section name="ipSecurity" overrideModeDefault="Deny" />
with:
<section name="ipSecurity" overrideModeDefault="Allow" />
✔ This worked for me on Windows server 2022 ✔

Related

IIS error 500.19 error when reading web.config

I am running IIS under Windows Server 2016 and I'm trying to run an ASP.Net core 3.1 application but I can't get past this error:
500.19 error
(The language in the picture is Hungarian, but it contains no useful information whatsoever, just an example)
Here is my web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Minibizz.Routing.Web.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
What am I missing?
P.S.: The web.config was created by Visual Studio 2019.
The reason behind the issue:
That error message goes on to say what exactly is bad about your configuration file, hence you should refer the “Config Error” and “Config Source” sections. This problem occurs because of the ApplicationHost.config file or the Web.config file contains a malformed or unsupported XML element.
if you are using url rewrite rule then install url rewrite Extention of iis. Enable ANCM logging, ie. set stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout\" (I think the path needs to end by a backslash), then run the web app and see if something gets logged into the stdout folder. Verify that the log directory exists at the path referenced by the web config. If it does not, create it. The path shown in your config would place the "logs" directory in the root folder of the deployed site. Verify that the application pool has to write access to the logs directory.
Make sure you installed the .net bundle.check that you installed below iis feature:
You may also need to verify that the path to the dotnet executable exists in the deployment machine's environment variables. To check this, first find the path where dotnet.exe is installed. It is generally located in either C:\Program Files\dotnet or C:\Program Files (x86)\dotnet. Once you know the path, ensure that the path exists in your Environment Variables.
The web.config content seems to be correct. If you use a clean web.config copy, does the problem persist? If the issue can be solved by replacing web.config with clean configuration content, then the problem is exactly with this web.config. In this case, I suggest you remove parts of the web.config content to narrow down the issue. If the pages show correctly after you remove one section, then the problem is with that section. You need double-check what's wrong with the section and update the correct configuration.
If the problem remains even with clean web.config content, I suggest you access other pages in different folders in your site to see if the problem still exists.
you could refer this below link for how to publish asp.net core site in iis:
https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-3.1&tabs=visual-studio

Access file using HTTP from Wildfly server

I am facing an issue related to file access over HTTP in Wildfly(JBoss).
I am running an application on Wildlfy-9.0.1.Final
In my application there is a link on click, it supposed to open respective file and display its content. But when I click on link it gives me 404-Not found error.
I could see that file exist on same path as given in href in anchor tag. I don't understand what it makes to give 404 Error.
Is there any other settings that I need to enabled in Wildfly to access files over HTTP. If so, please advice.
EDIT:
My path in <handlers> looks like this
path="/usr/local/jboss/server/default/deploy/"
This directory structure is not yet complete as there will be more path appended dynamically at run-time using java code where actual file will reside.
For ex: path="/usr/local/jboss/server/default/deploy/demo/1/filename"
of which /usr/local/jboss/server/default/deploy/ is static path and demo/1/filename is dynamic.
Also in /directory-listing-uri in location some path is dynamic generated at tun time.
For ex:
Assume below is directory-listing-uri
http://[wildfly host]:[port]/{static}/{dynamic}/{dynamic}/{dynamicFileName}.iif
So I am not sure how wildfly will serve my purpose of displaying files.
Please correct if I am incorrect.
To expose a directory for file listing (and download), you could add two configuration elements in your standalone.xml configuration (if you run wildfly as standalone server) like this:
<subsystem xmlns="urn:jboss:domain:undertow:2.0">
...
<server name="default-server">
...
<host name="default-host" alias="localhost">
...
<location name="/directory-listing-uri" handler="directory-listing-handler"/>
...
</host>
...
</server>
...
<handlers>
...
<file name="directory-listing-handler" path="/home/example/..." directory-listing="true"/>
</handlers>
...
</subsystem>
Note: For jboss-cli configuration, you can take a look at this answer
You will then get a nice Directory Listing GUI at this location:
http://[wildfly host]:[port]/directory-listing-uri

Adding custom section to web.config in ASP.NET 4

I've spent half of a day trying to understand why the following fails.
I can add section anywhere but never got it working like that ():
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<mysection />
<system.web>
<compilation debug="false" batch="false" targetFramework="4.0" />
</system.web>
<system.webServer>
<handlers>
</handlers>
</system.webServer>
</configuration>
I think the error related to .NET 4, because when you put section without pre-configuration in applicationHost.config it shows error with gray border saying that config is incorrect. That is what I expect. Then I add section definition and everything seems to work I can edit config from console - this means it is parsed correctly now.
But when I try to reach Application, it gives:
Parser Error Message: Unrecognized configuration section mysection
with a piece of config on yellow background.
Or do I need to write a module to consume that settings ? At the moment I do not have any, just a text in config.
following links will help you understand for this.
http://www.codeproject.com/Articles/32628/ASP-NET-Custom-Web-Configuration-Section
https://web.archive.org/web/20211020133931/https://www.4guysfromrolla.com/articles/032807-1.aspx
Regards,
Old topic but these links are very helpfull:
http://www.iis.net/learn/develop/extending-iis-configuration/configuration-extensibility
http://www.iis.net/learn/develop/extending-iis-configuration/extending-iis-schema-and-accessing-the-custom-sections-using-mwa
Edit (05/25/2016) :
The Details of how to store custom information in applicationHost.config file ... I hope this helps !
Note : These settings wont be visible on IIS Manager. There is a way to do that but thats beyond the scope of this response.
Requirement:
Need to extend the system.applicationHost/sites section of applicationHost.config file to allow a siteowner attribute at the site level. (IIS Does not allow us to do this by default). Nor can you manually edit the applicationHost.config file and add custom tags/attributes.
Steps:
Create a custom schema ( xml ) file under %windir%\system32\inetsrv\config\schema\ . File name: siteExtension_schema.xml
Include the custom elements that you want to eventually save in the applicationHost.config in that xml and save it with a appropriate name. The crucial thing to keep in mind is the sectionSchema tag.So when extending the schema of an existing section, simply create a element and set the name attribute to be the same as an existing section. In the schema file (see below), we have defined a with a name of "system.applicationHost/sites" - this is the same as the sectionSchema name in the default IIS_Schema.xml file in the Schema directory. So in essence you are instructing IIS to add these
<!-- Contents of %windir%\system32\inetsrv\config\schema\siteExtension_schema.xml -->
<configSchema>
<sectionSchema name="system.applicationHost/sites">
<collection addElement="site">
<attribute name="owner" type="string" />
<attribute name="ownerEmail" type="string" />
</collection>
</sectionSchema>
</configSchema>
Test the modifications by adding values for the "owner" and "ownerEmail" attributes that we included in step 2 above and then check the configuration file (applicationHost.config) to see the changes. Simply run the following command (must be elevated as Administrator) from the command line (uses appcmd ) to do so:
C:\> %windir%\system32\inetsrv\appcmd set site "Default Web Site" /owner:"John Contoso" /ownerEmail:"john#contoso.com"
To see if the configuration was applied, run the following command and check the output:
C:\> %windir%\system32\inetsrv\appcmd list site "Default Web Site" /config
<system.applicationHost>
<sites>
...
<site name="Default Web Site" id="1" siteOwner="John Contoso" siteOwnerEmail="john#contoso.com">
...
...
</site>
</sites>
</system.applicationHost>
To Read and Write your settings programmatically thru C# :
//this Will work with the ServerManager.OpenRemote("MyRemoteHostname") method also
using(var mgr = new ServerManager())
{
//Read
Console.WriteLine(mgr.Sites["Default Web Site"].Attributes["owner"].Value ); //Prints "John Contoso"
//Write
mgr.Sites["Default Web Site"].Attributes["owner"].Value = "New Owner";// Sets new value
mgr.CommitChanges(); // commits the changes to applicationHost.Config
}

IIS 7.5 error the requested resource can't be accessed

I'm trying to sort out my issue. i give all configuration issue but still getting this error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Config File \\?\C:\inetpub\wwwroot\WebSetup1\web.config
</modules>
116: <handlers>
117: <remove name="WebServiceHandlerFactory-Integrated" />
I also give access to Allow and in module also but still getting this error
using window 7 with IIS 7.5 + ASP.Net 3.5
any idea?
IIS 7.5 is a bear when it comes to user permissions. I would check that the defaultapppool or whatever your IIS user is for your app has permission to access the directory. Hope this helps.
Try to use in web.config
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<!-- ... -->
</system.webServer>

Encrypting custom sections of a web.config

I used the article Creating a Flexible Configuration Section Handler to create a Flexible Configuration Section Handler in my application.
I also saw this article entitled Encrypting Custom Configuration Sections on the OdeToCode blog, on how to encrypt portions of a web.config file.
From the first article, we have this web.config code.
<?xmlversion="1.0"encoding="utf-8"?>
<configuration>
<configSections>
<sectionname="StyleSheetSettings_1"
type="FifteenSeconds.Core.BasicConfigurator"/>
</configSections>
<StyleSheetSettings_1>
<StyleSheets>
<Style SheetName="Page"Href="Styles/Page.css"Media="screen"/>
<StyleSheetName="Custom"Href="Styles/Custom.css"Media="screen"/>
<StyleSheetName="Print"Href="/Lib/Styles/Print.css"Media="print"/>
</StyleSheets>
</StyleSheetSettings_1>
</configuration>
I tried to use the following code to encrypt the code using something like the following command line code.
aspnet_regiis.exe -pef "StyleSheetSettings_1" C:\Test\
I am getting the following error
Could not load type
FifteenSeconds.Core.BasicConfigurator'
from assembly 'System.Web,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'.
Any help would be appreciated.
Here's another workaround for this issue (found at http://www.dotnetnoob.com/2013/01/how-to-encrypt-custom-configuration.html). Comment out the section element for the custom section under the configSections element (/configuration/configSections) before running the aspnet_regiis command and the custom section should get encrypted.
<configSections>
<!--<section name="myCustomSection" type="My.Product.CustomSection, My.Product.Assembly/>-->
</configSections>
c:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pef myCustomSection C:\path\to\app
Microsoft (R) ASP.NET RegIIS version 4.0.30319.17929
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation. All rights reserved.
Encrypting configuration section...
Succeeded!
The only known solution is a terrible hack. Copy the assembly (and all dependencies) to the relevant .NET framework directory (where aspnet_regiis.exe is located).
trying change type to include the assembly name
type="FifteenSeconds.Core.BasicConfigurator, MyWebApplication"
This assumes the BasicConfiguration is in your Web App
I've had a similar problem when referencing a type in my configuration file. As Conrad Frix suggested, you need a reference to the assembly name after the namespace type reference. I have made the mistake of putting down what I think the assembly name is rather than checking it may have a different name to the name of the project. You can make sure by right clicking on the project in Visual Studio and going to properties. Double check to make sure that the project is outputting an assembly with the same name as you are specifying in your web.config.
Something like this might work, i havent tried it myself and not a clean solution
http://blogs.msdn.com/b/kaevans/archive/2004/08/19/217177.aspx
which uses System.Configuration.NameValueSectionHandler.
(System.Collections.Specialized.NameValueCollection) WebConfigurationManager.GetSection("SectionName")
I have tried this way though, using System.Configuration.SingleTagSectionHandler and
(Hashtable)WebConfigurationManager.GetSection("SectionName");
http://vaultofthoughts.net/UsingSingleTagSectionHandlerInsteadOfAppSettings.aspx
I just resolved a similar issue very easily. You need to specify the library within the "type" attribute.
Instead of:
<section name="StyleSheetSettings_1" type="FifteenSeconds.Core.BasicConfigurator"/>
Try:
<section name="StyleSheetSettings_1" type="FifteenSeconds.Core.BasicConfigurator, FifteenSeconds"/>
My issue was almost the exact same, although I was using the .NET libraries instead.
This:
<section name="Roles" type="System.Configuration.AppSettingsSection" />
Became:
<section name="Roles" type="System.Configuration.AppSettingsSection, System.Configuration" />
Hopefully this works.

Resources