简体   繁体   English

在IIS上部署ASPNet核心时,除root以外的其他URI上出现404错误

[英]Deploying ASPNet core on IIS got 404 errors on other URI than root

I have an ASPNet core application that run correctly on IIS Express with Visual Studio. 我有一个ASPNet核心应用程序,该应用程序可以在带有Visual Studio的IIS Express上正确运行。

I've tried to deploy this application on IIS Server 8.5 (With file folder). 我试图在IIS Server 8.5(带有文件夹)上部署此应用程序。 If I access to the root URI (/), my page appears correctly (Status 200). 如果我访问根URI(/),则我的页面正确显示(状态200)。 But if I try to access to other URI (ex: /Meetings), I get a 404 errors. 但是,如果我尝试访问其他URI(例如:/ Meetings),则会收到404错误。

Another things, I have tried to change the identity of the application pool to administrator and it works. 另外,我尝试将应用程序池的标识更改为管理员,并且可以正常工作。 But I know that it's not the best practice and I can't find why it's not working with the app pool identity. 但是我知道这不是最佳实践,我无法找到为什么它不能与应用程序池标识一起使用。
Below some configuration, ask me if you want specific file: 在一些配置下,请问我是否需要特定文件:

web.config : web.config:

<configuration>

<!-- To customize the asp.net core module uncomment and edit the following section. 
For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
    <remove name="aspNetCore"/>
    <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>
</configuration>

Access logs : 访问日志:

2018-07-18 13:14:08 ::1 GET /Meetings - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/67.0.3396.99+Safari/537.36 - 404 0 0 1422
2018-07-18 13:22:54 ::1 GET / - 80 - ::1 Mozilla/5.0+(Windows+NT+6.3;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/67.0.3396.99+Safari/537.36 - 200 0 0 1841

App pool configuration : 应用程序池配置:
应用程序池配置

I have also tried to change the permission to the folder, but not working. 我也尝试过更改该文件夹的权限,但是不起作用。

If someone already had this problem, I'm ready to try different solutions. 如果有人已经遇到此问题,我准备尝试其他解决方案。

Thanks, 谢谢,

EDIT : 编辑:

Detail log of the 404 error here : https://paste.ee/p/4PBzY 404错误的详细日志在这里: https : //paste.ee/p/4PBzY

EDIT 2 : 编辑2:

I have found this information in the windows events, but I have a connection string and my SQL Server is congured with local account. 我在Windows事件中找到了此信息,但是我有一个连接字符串,并且我的SQL Server与本地帐户配置在一起。

在此处输入图片说明

Ensure you have the performed the following steps: 确保已执行以下步骤:

  1. You need to publish your website and then point IIS website to the published folder 您需要发布您的网站,然后将IIS网站指向发布的文件夹
  2. Application pool must be set to No Managed code 应用程序池必须设置为“ No Managed code
  3. Application Pool identity user IIS AppPool\\{AppPoolName} must have read permissions on the published website folder. 应用程序池标识用户IIS AppPool\\{AppPoolName}必须对已发布的网站文件夹具有读取权限。 Change the identity of your application pool to ApplicationPoolIdentity . 将您的应用程序池的标识更改为ApplicationPoolIdentity For application pool identity there will be user account with name IIS AppPool\\{Applicaiton Pool name} eg for DefaultAppPool the user account is IIS AppPool\\DefaultAppPool so you can allow read/write access to your to Applicaiton Pool user on published application folder 对于应用程序池标识,将有一个名称为IIS AppPool\\{Applicaiton Pool name}的用户帐户,例如对于DefaultAppPool,该用户帐户为IIS AppPool\\DefaultAppPool因此您可以允许对已发布的应用程序文件夹上的Applicaiton Pool用户进行读/写访问

在此处输入图片说明

Ok, I've finally found where was the problem. 好的,我终于找到了问题所在。

After look at the event viewer, I saw that application try to connect to my SQL Server with the ApplicationPoolIdentity, as can you see on the screen below (sorry for the french screen) 看完事件查看器后,我看到该应用程序尝试使用ApplicationPoolIdentity连接到我的SQL Server,如您在下面的屏幕上看到的(对不起,法语屏幕)
在此处输入图片说明

So, I have just add this user into SQL Server with permissions on my database and configure like Mohsin Mehmood advises me (see other answer), and now it works ! 因此,我已经将该用户添加到具有数据库权限的SQL Server中,并按照Mohsin Mehmood的建议(请参阅其他答案)进行配置,现在它可以正常工作了! 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM