ASP.NET 5 An error occurred while starting the app

2019-01-24 00:40发布

After publishing an ASP.NET Web App, I'm trying to host the website on my local server. However, when I start it up, it gives me this error in my browser:

Oops. 500 Internal Server Error An error occurred while starting the application.

How can I debug what this error is? The website works (both Debug and Release configurations) when starting using IISExpress and "web" in Visual Studio.

I am using the Development environment, and I have already specified app.UseDeveloperExceptionPage();.

I have followed the instructions here to deploy to IIS.

I've also tried the suggestion offered here (re-publishing with "Delete all existing files prior to publish" selected). (The OP there has a slightly different error, so that's why I'm posting a new question.)

I've looked for hours on the internet, but there doesn't seem to be much content about it. Any ideas?

I am on Windows 7, using ASP.NET 5 RC1.

4条回答
冷血范
2楼-- · 2019-01-24 01:07

The Problem: most likely this error is due to insufficient privileges for the Application Pool Identities. To find out:

Go to windows Task Manager and under Details tab / Processes (Depending on Windows OS) look for w3wp.exe and under User name look for your application (<App_Pool_Name> usually DefaultAppPool) running there as an IIS Worker Process. If your app is not listed there, then the App has insufficient privileges with your database.

To Fix it: do the following and give full access to your App:

Go to your SQL Server Management Studio and Login as Administrator open Security > Logins > right click Logins and add a New Login:

Under General:

  • for Login Name: Enter IIS APPPOOL\<App_Pool_Name> usually DefaultAppPool

  • for Default Database: point to <Your_App_Database>

Under User Mapping:

  • on the box Users mapped to this login:

    -Check the box to Map to <Your_App_Database>

    -Under user Enter IIS APPPOOL\<App_Pool_Name>usually DefaultAppPool

    -Under Default Schema Enter dbo

  • on the box Database role membership for: <Your_App_Database>

    -Check the following boxes: db_datareader, db_datawriter, and public

Click OK

Now try to access your App and it should work!!!

查看更多
Explosion°爆炸
3楼-- · 2019-01-24 01:09

This error also occurs when you are attempting a database connection from the startup (eg for seeding) and it fails on the deployment server due to insufficent previleges at the database server.

查看更多
Evening l夕情丶
4楼-- · 2019-01-24 01:20

This error occurs under several conditions. In my situation, I did not have the database connection string set correctly. I fixed it in Visual Studio 2017 as follows:

1) Right-click project, select Publish, open the Publish page in main area.

2) Select the Publish tab on the left

3) Under Summary section, there's a "Settings..." link. Click it. This opens the Publish dialog.

4) Click Settings tab on the left.

5) Expand File Publish Options, check "Remove additional files at destination"

6) Expand Databases, check "Use this connection string at runtime" (This was pre-populated with my Azure SQL connection string based on how I originally set up my publish options)

7) Expand Entity Framework Migrations, check "Apply this migration on publish" (Again, connection string was pre-populated)

8) Click Save

9) Publish

10) Cross your fingers

查看更多
霸刀☆藐视天下
5楼-- · 2019-01-24 01:24

You should set the stdoutLogEnabled=true in the web.config file to see the actual error that is happening. You can direct where these files are written with the stdoutLogFile argument; the screenshot example below writes to stdoutLogFile=".\logs\stdout". (You should ensure the directory exists; the app won't create it)

As for not being able to find the proper config file yes the default environment is production. It is set to development explicitly in visual studio in the project properties.

Update: In AspNetCore RTM the module is called aspnetCore under the system.webServer node in web.config. Also, as @ErikE pointed out in comments, the web.config is now located in the root of the project and not under wwwroot as in previous releases.

enter image description here

查看更多
登录 后发表回答