We have a Web API webservice site, built in .NET 4.5.2, that we're trying to move to .NET 5.0.
We ran into what seems to be a common issue - when we deploy the site to our staging environment, none of the PUT and DELETE methods work. When we test them using the generated Swagger UI, we get 500 errors.
Note - we do not see these errors running in IIS Express, through the VS2019 debugger.
We browse the web, of course, and find an answer:
How do you fix a 500 Server Error while running REST PUT or DELETE requests?
So we create a web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="WebDAV" />
</handlers>
<modules>
<remove name="WebDAVModule" />
</modules>
</system.webServer>
</configuration>
And that causes different problems.
We get HTTP 500 errors when we try to run the site in IIS Express through the VS2019 debugger, and
Running the site modifies the web.config.
The web.config now looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="WebDAV" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<modules>
<remove name="WebDAVModule" />
</modules>
<aspNetCore stdoutLogEnabled="false" hostingModel="InProcess" />
</system.webServer>
</configuration>
Note the addition of aspNetCore.
So, here's the thing.
We need this to work both when deployed to IIS, and when run locally, and
We can't have source files that are partially generated, during the build. Our whole build-and-version-control system is built on the idea that there are files that contain code that developers write and there are files that are generated during the build. The former we save version control and the latter we do not. We can add web.config to our version control, but if we do we cannot have its contents changing during a build or run.
So, what do we do?
How do we get this to work when deployed in IIS and when run in IIS Express when debugging?
And how do we deal with the web.config being modified during a debug run?
These sort of issues seem to show up for a great many reasons, and I can't pretend to have found an answer to all of them.
In this particular case, the problem was that VS was inserting bad elements into the web.config.
Adding the <handlers/> and <modules/> elements to remove the WebDAV caused VS to insert an <aspNetCore/> element:
<aspNetCore stdoutLogEnabled="false" hostingModel="InProcess" />
And the element that was inserted lacked the required processPath= attribute.
<aspNetCore processPath="dotnet" stdoutLogEnabled="false" hostingModel="InProcess" />
It is better to turn off WebDAV Publishing.
To do that :
Open "Turn Windows Features on or off". Now inside Internet Information Services\World Wide Web Services\Common HTTP Features\WebDAV Publishing. Uncheck it and click OK.
Related
I published my asp.net (net core app 2.1) to windows 2012 r2 at localhost::80.
It gives me the following error:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information:
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x8007000d
Config Error
Config File \web.config
Requested URL :80/
Physical Path
Logon Method Not yet determined
Logon User Not yet determined
As far as I checked, the error seems to be in web.config
I'll put the web.config in the code section.
I have tried deleting the web.config and enabling directory browsing, making an index.html load index.cshtml but that won't work because MVC.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<modules>
<!-- Remove WebDAV module so that we can make DELETE requests -->
<remove name="WebDAVModule" />
</modules>
<handlers>
<!-- Remove WebDAV module so that we can make DELETE requests -->
<remove name="WebDAV" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<!-- When deploying on Azure, make sure that "dotnet" is installed and the path to it is registered in the PATH environment variable or specify the full path to it -->
<aspNetCore requestTimeout="23:00:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="false" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" startupTimeLimit="3600">
<environmentVariables />
</aspNetCore>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
I expected it to start but as it happens I get the error.
Thank you for your help.
I had the same error and I solved it by installing URL Rewrite using the Web Platform Installer in the IIS manager.
I have a project written using C# on the top of Asp.NET Core 2.2 framework.
I was able to publish it to my VPS. But, when I try to access the website I get the following error
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Here is the content of the web.config file located in the root
<?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="dotnet" arguments=".\ProjectName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 47b26df0-8a01-4d75-9549-3a98654550a3-->
The web.config file was published via Visual Studio along with the rest of my files. But I don't see web.config file in my solution.
This file seems to be invalid. How can I fix the web.config file?
If I remove the web.config file and add index.html page the site work. It sounds to me that web.config the file is invalid for some reason.
Updated
I am able to run the application using the command line.
using the command line, I did the following
I change directory into the root of my website (i.e cd C:\inetpub\wwwroot\ProjectName)
I execute the following command dotnet ProjectName.dll
10 seconds later, I got some information that the app is running and it showed me the URL it is listing to. In my case it was http://localhost:5000
O used the browser to browser http://localhost:5000 and it works fine.
But when I access it using the domain name, I still get Http Error 500.19 as stated above.
As discussed in comments
Install AspnetCore module in iis
Setup ASPNETCORE_ENVIRONMENT to production in your environment or
setup in web.config.
<aspNetCore processPath="dotnet"
arguments=".\MyApp.dll"
stdoutLogEnabled="false"
stdoutLogFile="\\?\%home%\LogFiles\stdout"
hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
</environmentVariables>
</aspNetCore>
I did upgrade of my app to aspnetcore 2.2 but due to some legacy limitations which I am planing to remove later I must target .NET Framework.
New hosting model InProcess bring improvements so I want to use it but when I deploy to azure I am getting error.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<!--AspNetCoreModuleV2 switch back when its released on azure-->
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Flymark.Online.Web.exe" arguments="" stdoutLogEnabled="true" stdoutLogFile="../stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
And my error
HTTP Error 500.0 - ANCM In-Process Handler Load Failure Common causes
of this issue: The specified version of Microsoft.NetCore.App or
Microsoft.AspNetCore.App was not found. The in process request
handler, Microsoft.AspNetCore.Server.IIS, was not referenced in the
application. ANCM could not find dotnet. Troubleshooting steps: Check
the system event log for error messages Enable logging the application
process' stdout messages Attach a debugger to the application process
and inspect For more information visit:
https://go.microsoft.com/fwlink/?LinkID=2028526
If I change same app to be outofprocess and module to v1 it works as expected
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<!--AspNetCoreModuleV2 switch back when its released on azure-->
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Flymark.Online.Web.exe" arguments="" stdoutLogEnabled="true" stdoutLogFile="../stdout" hostingModel="OutOfProcess" />
</system.webServer>
</location>
</configuration>
I am publishing my app using Azure pipelines and MSbuild.
As of today it seems In-Process is not supported when targeting .Net Framework. Issue on github
In my case, I get the shared web.config from my colleague and the build path is not correct for me. Correct the path then it works!
I'm trying to host .Net Core2 default WebApi project on my Local IIS Server in Windows 10.
I just published the default project to a local folder without making any change on it and hosted it on IIS.
But it gives me this error when I try to access the URI
My web.config file as follow:
<?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=".\ToHost2.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: 3be731b8-79e8-4828-a016-54606c34c081-->
Please help me to track where I have made mistake.
Thanks in advance
You need to install the .NET Core Windows Server Hosting bundle
Convert the Web api project folder as application in IIS tool.
right click on api project folder and convert as application i think it will be work for you
I'm building a web service against .NET 4.6.1 on ASP.NET Core. Locally it has been fine - I can debug no issues and everything works. Recently I took to getting it up online as an Azure Web App, which also works no problems now. The service loads and runs fine.
However I cannot remote debug it. When I do try to remote debug it, although it attaches no problems none of the break points fire and they turn hollow with the error No symbols have been loaded for this document.
I have tried and/or confirmed:
It is a debug build being pushed to a slot set to debug on VS 2015.
I've tried downgrading .NET to 4.6.
I've wiped out the Web App entirely and made a new one from scratch.
All extensions in VS 2015 are up to date.
In the VS Modules window, no modules or symbols have been loaded.
I have confirmed there is a PDB file present next to the app executable.
I have tried unchecking the "Just my code" checkbox in VS.
The Web App is configured for x64.
I have tried it on a completely different PC.
My web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true" />
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="false" stdoutLogEnabled="false" />
</system.webServer>
</configuration>