ASP.NET Core IIS Trouble-shooting
▌Introduction
A tutorial about how to deploy ASP.NET Core application
to IIS.
▌Environment
▋IIS 7.5 on Windows 7 and IIS 6.1 on Windows server 2018 R2
▋.NET Core 2.0.2
▋Visual Studio 2017 Community
▌Web Server
▋Install .NET Core SDK
You
can find the latest .NET Core SDK here.
▋Install Microsoft Visual C++ 2015 Redistributable
▋Install .NET Core Windows Server Hosting bundle
▋Install Web Deploy
Install Web Deploy toolkit by Web Platform
Installer.
PS.
I have no luck when deploying with Web Deploy 3.6 on IIS6.1.
So I installed the version 3.5
I have no luck when deploying with Web Deploy 3.6 on IIS6.1.
So I installed the version 3.5
▋Create Website on IIS
Create website and make sure that it uses the Application
Pool like this.
(The en-US
picture on docs.microsoft.com)
▌Deploy
▋Visual Studio: Publish
For Publish references, take a look at these article.
ASP.NET Core templates do not have WebConfig in default.
You can add one in to the project, or there be one created to web server when
deploying the application.
The WebConfig is like this
<?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=".\XXXX.Webapi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: 8e632a21-d7e5-4576-be88-2052e525bc07-->
|
Notice that ASP.NET Core use the above settings with
yellow color to host itself and listen to certain port as following in
EventLog. And thaz why we have to install .NET Core Windows Server
Hosting bundle.
▋Enable stdoutLog
I recommend to enable stdoutlog in the early stage to
gather useful message from hosing the application.
1.
Update WebConfig by setting stdoutLogEnabled="true".
2.
Create a folder: logs (depends on stdoutLogFile=".\logs\stdout") and set permissions on it
for the Application Pool.
I always forget the second step :Q
▌Trouble shooting
▋0x80004005
Application 'MACHINE/WEBROOT/APPHOST/MYAPP'
with physical root 'C:\inetpub\wwwroot\MyApp\' failed to start process with
commandline 'dotnet .\MyApp.Webapi.dll', ErrorCode = '0x80004005 : 80008081.
|
This the common error we may encounter. Check
1.
Does dotnet.exe in system path?
2.
Are all custom folders, like logs, upload folders, set
the permission for Application Pool?
3.
Often happens on initializing the application.
▋GET 401 (Unauthorized) on Web API
While I put more than one web application in the same
domain, the 401 error message showed when a website calling the HttpGet method from
another Web API.
Reference to this article:
The problem occurs when
the Web site uses Integrated Authentication and has a name that is mapped to
the local loopback address.
I used the Method 2. Disable the loopback check, to get
rid of this issue.
1.
Open regedit
2.
Find [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
4.
Set Name: DisableLoopbackCheck,
Value: 1
5.
Restart the web server
▌Reference
沒有留言:
張貼留言