简体   繁体   中英

ASP.NET 5 IIS 500 error with EF7 application

I am hosting an application in IIS 8 which is developed in ASP.NET 5, MVC 6, and EF7. I have created API for the application which is accessible via http://localhost/api and I have created few controllers to access data.

When I access the API from visual studio everything works fine, and I able to retrieve JSON data back. But when I host the application IIS 8 and browser localhost/api/controller , I get 500 error in IIS logs. I also have http platform handler 1.2 installed on windows server 2012 r2 server. I am actually able to browse static pages and other links like localhost/home , but when I try to access api controller I get 500 error code back.

Now when I use execute web.cmd file from the application to self host the application and browse localhost:5000/api/controller , I am able to retrieve json data back, but not from IIS hosted site.

Since I dont know what is the problem, I enabled Failed request tracing rules and I was able to capture logs with 500 error. Below is the screenshot:

在此输入图像描述 在此输入图像描述 在此输入图像描述 在此输入图像描述 在此输入图像描述 在此输入图像描述 在此输入图像描述 在此输入图像描述 在此输入图像描述

Not getting this from your failed request logs, but might I suggest the usual suspects since you say it works outside of IIS:

  1. Confirm that the App Pool is set to work with .NET 5.0 and isn't set to a different CLR like 2.0 or 4.0. ( Actually strike this, since non-API MVC controllers wouldn't have worked at all in that case... )

  2. Confirm that the App Pool is running with an Account that has sufficient database permissions if using NTLM security with SQL, since the execution context may be different when running IIS Express from Visual Studio versus IIS.

I would also suggest checking the Windows Error logs, not just request trace....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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