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
Related
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.
I am trying to deploy simple dotnet application (dotnet new webapi) into azure, through the FTPS,
But I always see the the same picture by the azure's URL:
The configuration/General settings:
Stack: .NET Core
Major version: 3.1
Minor version 3.1.0
Startup Command: dotnet < name >.dll
I have tried to publish through Visual Studio with FTP deployment with profile ("Get publish profile" button in the overview). Also I have tried to send all files manually through FTPS. The path i took from publish profile file.
Note: I switched stack to PHP and passed index.html through the FTPS manually - it worked.
Is there step by step guide, to deploy asp net core app through FTPS?
You need to create a web.config file under your website folder:
The content of web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\CoreWebApplication.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" />
</system.webServer>
</location>
</configuration>
Note to change CoreWebApplication.dll to your own dll file.
Then, use FTP to upload all files to Azure Web App site\wwwroot\ folder:
Finally, restart your web app to check if your .NET Core application was successfully deployed.
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'm trying to host two ASP.Net core application in one IIS app pool. I've created application pool and site which is linked to inetpub/myapps/myapp1 folder, then I chose Add Application in newly created site linked to inetpub/myapps/myapp2 with alias: myapp2
There is web.config in myapp1 folder with following content:
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\myapp1.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
<system.webServer>
Application myapp1 is working normally but when I'm trying to add same thing to myapp2 there is configuration error appears.
I even removed handlers section, made it with different name but unfortunately nothing.
Is there any documentation or best practice to host two asp.net core apps within one application pool?