IIS error 500.19 error when reading web.config - asp.net

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

Related

Enable directory browing for ASP.NET projects published from Visual Studio

I am trying to import an ASP.NET project which I know works and I am trying to build it on local. I imported the solution file in Visual Studio and went ahead and did a Clean and Build on it which went ok. Now I am trying to Publish the project and once I do that, I clicked the run button which says IIS Express and I see the following
HTTP Error 403.14 - Forbidden
Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
If I was running this application out of IIS Manager, I know how to resolve this by clicking on the project, clicking Directory Browing and clicking Enable but I don't know how to fix this issue if I am running it from inside Visual Studio.
To resolve the issue you could try one of the below ways:
1)Set the below code in the web.config file:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true" />
</system.webServer>
2)Set the default page for your project:
<system.webServer>
<defaultDocument>
<files>
<add value="pagename.aspx" />
</files>
</defaultDocument>
</system.webServer>
if you are using the MVC site then set default routs.

IIS (There was an error while performing this operation)

I receive There was as error while performing this operation error referring to web.config. I follow below configuration:
OS is Windows server 2012 R2 with IIS version 8.5.
URL Rewrite 2.1 module is installed on the machine.
IIS_IUSRS has full access to the directory.
Application Initialization module is installed
.Net CLR Version v4.0.30319 and managed pipeline mode is integrated.
IIS configuration is as below:
Web config is as below:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\MES.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: e8701310-485f-4f88-b7d0-1473d07238ac-->
browsing the page I receive below message:
However, when I remove
<aspNetCore processPath="dotnet" arguments=".\MES.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
from web.config I don't receive (There was as error while performing this operation) error but I get below error:
This error occurred for me when trying to double-click on the Logging module for any site with a bad Web.config.
"Bad" includes Web.configs that just have a module IIS doesn't understand - in my case, IIS 10 couldn't understand the <rewrite> tag, and exploded with this extremely confusing error.
You can verify this by just commenting out the contents of your Web.config. The error goes away - then just gradually reduce how much is being commented out until you find the culprit, and track down that solution.
Add <aspNetCore> back and also install ASP.NET Core module on this machine,
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/aspnet-core-module?tabs=aspnetcore2x
I also wrote a tool to better automate such detection,
https://www.jexusmanager.com/tutorials/oob-500.html
This error is typically caused by a reference inside the web.config which cannot be resolved by the dotNet runtime.
If you are using dotNet core, AND you installed the dotNet core hosting bundle BEFORE you configured your server to run IIS you may get this error.
To fix it in this case, you need to re-run the dotNet core hosting bundle installer AGAIN, in "repair mode"
As described in the box entitled "Important", here.
I had this problem with .NET Core 2.1.
I installed 2.1 SDK (v2.1.301) and as Microsoft says Hosting Bundle now installs with SDK, but in my case this did't work.
This problem disappeared only when I installed 2.1 Runtime (v2.1.1) for Hosting Bundle Installer.
Maybe you need to install URL Rewrite
I had same problem.

Http Error 404:14 - Forbidden

I've installed my web application already in IIS. But when we run it, it contains HTTP Error 403.14 - Forbidden. I've researched about the solutions.
Enabled Directory Browsing.
-But enabling directory browsing is not allowed.
Add Defalut Document
-I already have a default Document.
So now, I'm practically lost on how to solve this issue.
Have you already registered the framework for iis in the computer?
C:\windows\Microsoft.NET\Framework64\v4.0.30319> .\aspnet_regiis.exe -ir C:\windows\Microsoft.NET\Framework64\v4.0.30319> iisreset
run that in command prompt
Note: Path will of course change depending on your local drive
I've already solved this issue. There's just something wrong with my default document in my web.config. I used ~/Login.aspx instead of Login.aspx.
<defaultDocument enabled="true">
<files>
<clear />
<add value="Login.aspx" />
</files>
</defaultDocument>

What files can be downloaded from a website root directory?

If i have a page on my website called blah.aspx then there will be another file there called
blah.aspx.vb
I can browse to blah.aspx but if I try to browse to blah.aspx.vb, I'll get 'file not found' page.
If I change the name of blah.aspx.vb to blah.zip it can be downloaded via the browser.
If I change the name to blah.qaz I'll get the 'file not found' again.
I suspect that the server will not allow the .aspx.vb file to be downloaded but if it doesn't protect a .zip file why does it protect a made up .qaz or is that just a shortcoming of the browser?
Are there file extensions that a server will actively protect?
Are there file extensions it deliberately won't hide (e.g zip)?
What are the rules and where can you find them?
IIS 7 maps 'allowed' extensions (or extensions that it will handle) in the applicationhost.config file.
If you really want to allow a 'qaz' extension, you could add a mimeMap to add it as static content. Don't know what webserver you're using, but if you're on II7+, you should be able to add it to your web.config:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".qaz" mimeType="text/plain" />
</staticContent>
</system.webServer>
</configuration>
If you're on an earlier version of IIS, then it's a different ballgame. If you're on some other webserver, you'll have to search around for the configuration information, but most will have some configuration file that states which extensions they are ok serving.

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>

Resources