为什么我的MVC 5 ASP.Net应用程序在本地工作,但在部署到Azure时却不能工作? [英] Why my MVC 5 ASP.Net App Works Locally but not when Deployed to Azure?

查看:85
本文介绍了为什么我的MVC 5 ASP.Net应用程序在本地工作,但在部署到Azure时却不能工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里的第一个问题,希望有人能帮助我.

My first question here, I hope someone can help me out.

我是开发ASP.Net应用程序的新手,并且最近完成了一个围绕赛车手,车队等的小型项目,该项目在本地运行良好,但当我将其部署到Azure时效果不佳.

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.

我注意到的第一个问题是CSS没有在已部署的版本上加载.默认页面,主页",关于"和联系"都可以正常工作(尽管没有样式),但是我在模型中创建的页面返回错误页面,仅显示

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.

我已经在网上进行了一些搜索,以帮助我确定问题所在,并且我在Stackoverflow上找到了一些建议来设置 <customErrors mode="Off"/> 以获得更详细的错误报告,但是我在Web.config或项目的其他地方找不到任何这样的选项.我正在使用Visual Studio Enterprise 2015,这有什么不同吗? customErrors是否会贬值?

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.

虽然我列出了2个数据库,但在部署时,我在Visual Studio的发布Web/设置"菜单中选中了执行代码优先迁移"框, ApplicationDBContext(defaultConnection)和 MyModelContext(我自己创建的那个). ApplicationDBContext上的复选框为灰色,因此我只能为MyModelContext选择一个.

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.

在我的Web.config中,我有2个连接字符串,一个用于包含我所有AspNetUsers表的DefaultConnection,另一个名为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.

我正在运行Visual Studio Enterprise 2015,SQL Server 2014,Windows10.

I'm running Visual Studio Enterprise 2015, SQL Server 2014, Windows 10.

打开程序包管理器控制台时,我发现此错误.我不确定是否相关,但认为它可能有用.

I found this error when opening the Package Manager Console. I'm not sure if it's related but thought it might be useful.

"System.Management.Automation.Runspaces.InitialSessionState"的类型初始值设定项引发了异常.

The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception.

推荐答案

以下是一些常规调试建议: 如果您具有一致的复制,则可以使用远程调试来附加到您的Web应用程序并对其进行调试(

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/).

否则,您可以使用Web应用程序设置启用更好的诊断日志.有关操作方法的信息,请参见: https://azure .microsoft.com/en-us/documentation/articles/web-sites-configure/在启用诊断日志"部分下.在您的情况下,应该启用应用程序日志记录,也许失败的请求跟踪会很有用(FREB).

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).

对于更多工具,您可以使用支持网站扩展( https://channel9.msdn.com/Events/Ignite/2015/BRK4704 .

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.

现在,听起来您的问题可能与数据库迁移有关.通过使用SSMS连接到您的应用程序引用的数据库,仔细检查一切是否正常.

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.

这篇关于为什么我的MVC 5 ASP.Net应用程序在本地工作,但在部署到Azure时却不能工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆