问题
My first question here, I hope someone can help me out.
I'm new to developing ASP.Net applications and have recently completed a small project based around racing drivers, teams etc which works fine locally but not when I've deployed it to Azure.
First issue I noticed was that the CSS didn't load on the deployed version. The default pages, Home, About and Contact all work fine (though without my styling) but the ones I created myself off my models return an error page saying only
Error. An error occurred while processing your request.
They work fine in the Local version.
I've done some searching online to help me identify the issue and I found suggestions here on Stackoverflow to set the
<customErrors mode="Off"/>
to get a more detailed error report of whats happening, however I can't find any such option in my Web.config or elsewhere in the project. I'm using Visual Studio Enterprise 2015, if this makes any difference? customErrors depreciated maybe?
I followed a couple of guides to complete the deployment to the letter, including one that was supplied by my lecturer that I know has worked for others so I'm a little confused as to where the problem could lie.
I checked the box for "Execute code first migrations" in the publish web/settings menu in Visual Studio when deploying, though I have 2 databases listed, ApplicationDBContext(defaultConnection) and MyModelContext (the one I created myself). The checkbox on ApplicationDBContext is greyed out so I could only select the one for MyModelContext.
In my Web.config I have 2 connection strings, one for the DefaultConnection where all my AspNetUsers tables are contained and another called MyModelContext where my own tables are contained for the racing drivers, teams etc.
Please let me know If I need to be more specific about my problem.
I'm running Visual Studio Enterprise 2015, SQL Server 2014, Windows 10.
EDIT: I found this error when opening the Package Manager Console. I'm not sure if it's related but thought it might be useful.
The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception.
回答1:
Here is some general debugging advice: If you have a consistent repro, then you can use remote debugging to attach to your web app and debug it (https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-troubleshoot-visual-studio/).
Failing that, you can enable better diagnostic logs using the web app settings. Information on how to do so is here: https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure/ under the section "Enabling diagnostic logs". In your case you should have application logging enabled, and perhaps failed request tracing would be useful (FREB).
For even more tools you can use the Support Site Extension (http://azure.microsoft.com/blog/2014/12/01/new-updates-to-support-site-extension-for-azure-websites/) which would allow you to look at live event logs and HTTP traffic. For a deeper dive into debugging in Azure App Service see: https://channel9.msdn.com/Events/Ignite/2015/BRK4704.
Now, it sounds like your problem is probably related to the database migration. Double check that everything looks good by connecting to the database referenced by your app with SSMS.
来源:https://stackoverflow.com/questions/34292280/why-my-mvc-5-asp-net-app-works-locally-but-not-when-deployed-to-azure