【发布时间】:2015-03-07 14:56:39
【问题描述】:
我有一个完美运行的 MVC 项目(本地),但是在我将它发布到 Azure 之后(通过下载 Azure 发布配置文件、导入并发布),每当我在上传的站点上执行一个操作时,我都会得到一个标准错误屏幕需要与数据库联系。比如登录或搜索网站上的其他资料。
它只是给了我一个简单的“发生错误”消息,没有详细说明问题所在?我尝试在服务器上启用详细的错误消息,但它并不关心它只是给出相同的错误消息而没有解释。
我尝试了各种通过搜索引擎找到的东西。但我无法确定我的问题。我怀疑它与服务器上的网络配置文件有关吗?但我不能确定。
更新:我现在实际上是发布特定问题而不是一般消息,并且似乎由于某种原因未创建使用身份框架时创建的普通表?哪个对我来说很奇怪?我的意思是我确实将我拥有的两个不同的 dbcontext 类合并到标准 ApplicationDbContext 类中,但在本地它仍然存储了所有用户等。为什么当我发布它时它不再创建这些表?
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<connectionStrings>
// REMOVED SENSITIVE INFO
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<authentication mode="None" />
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
<staticContent>
<remove fileExtension=".svg" />
<remove fileExtension=".eot" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/x-woff" />
</staticContent>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
<contexts>
<context type="MEV3.Models.ApplicationDbContext, MEV3">
<databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[MEV3.Models.ApplicationDbContext, MEV3], [MEV3.Migrations.Configuration, MEV3]], EntityFramework, PublicKeyToken=b77a5c561934e089">
<parameters>
<parameter value="DefaultConnection_DatabasePublish" />
</parameters>
</databaseInitializer>
</context>
</contexts>
</entityFramework>
</configuration>
【问题讨论】:
-
尝试在您的 web.config 文件中将
customErrors设置为off:msdn.microsoft.com/en-us/library/h0hfz6fc%28v=vs.100%29.aspx。您应该能够查看有关应用程序在部署到 Azure 时失败的原因的详细错误。很可能是缺少 DLL 或不正确的数据库连接字符串。 -
试过了,现在当我尝试访问该站点时,我只是得到一个带有此文本的空白页面...“由于发生内部服务器错误,该页面无法显示。 "
-
您可以在这里分享您网站的链接吗?
-
如果
Detailed Error Messages设置为on,您可以检查您的web.config:<system.webServer> <httpErrors errorMode="Detailed" /> <asp scriptErrorSentToBrowser="true"/> </system.webServer> -
当然这里是链接,除了自动播种的管理用户之外,数据库中没有任何内容。 case-system.azurewebsites.net
标签: azure asp.net-mvc-5 publish