0

I have a perfectly working MVC project (locally) but after I publish it to Azure (by downloading the Azure publish profile, importing it and publishing) I just get a standard error screen whenever I perform an action on the uploaded site that requires contact with the database. Like logging in or searching through other materials on the site.

It just gives me a simple "An error has occurred" message with not details on what's wrong? I tried enabling detailed error messages on the server but it doesn't care about that it just gives the same error message with no explanation.

I tried all kinds of things I found via a search engine. But I can't pinpoint my problem. I suspect it has something to do with the web config file on the server though? But I can't be sure.

UPDATE: I actually got it to post the specific issue now instead of the general message and it seems that for some reason the normal tables which are created when using the identity framework are not created? Which is strange to me? I Mean I did merge two different dbcontext classes I had into the standard ApplicationDbContext class, but locally it still has all the users stored etc. How come it's not creating those tables when I publish it anymore?

<?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>
halfer
  • 19,824
  • 17
  • 99
  • 186
ObedMarsh
  • 433
  • 4
  • 19
  • 1
    Try setting the `customErrors` to `off` in your web.config file: https://msdn.microsoft.com/en-us/library/h0hfz6fc%28v=vs.100%29.aspx. You should be able to view the detailed error as to why the application is failing when deployed to Azure. Most likely it could be either a missing DLL or incorrect DB connection string. – Gaurav Mantri Mar 07 '15 at 15:03
  • Tried that and now I'm just getting a blank white page with this text on it when I try to visit the site... "The page cannot be displayed because an internal server error has occurred." – ObedMarsh Mar 07 '15 at 15:10
  • Will it be possible for you to share the link to your website here? – Gaurav Mantri Mar 07 '15 at 15:12
  • 1
    You can check in your web.config if `Detailed Error Messages` is set to `on` : ` ` – Guy Mar 07 '15 at 15:16
  • Sure here is the link, there's nothing in the database anyways except the automatically seeded administrative user. http://case-system.azurewebsites.net/ – ObedMarsh Mar 07 '15 at 15:20
  • If you are using IE, this answer could help you : http://stackoverflow.com/a/15008842/1226103 – Guy Mar 07 '15 at 15:26
  • Im not I'm using firefox and the problem is the same in any browser. – ObedMarsh Mar 07 '15 at 15:28
  • So I ran the website and traced the request/response in Fiddler. Your server is sending back HTTP Status Code 500 which means your application is experiencing an unhandled exception. However it seems you're returning standard error message back. Can you include your web.config file (**please mask any secret information like DB connection string**) in your question? BTW, did you make the changes suggested by @Guy? – Gaurav Mantri Mar 07 '15 at 15:29
  • I posted the remote web config file and I tried making those changes but the error msg remains the same. – ObedMarsh Mar 07 '15 at 15:41
  • I found out some more, please see my update in the question and see if you can help now? – ObedMarsh Mar 07 '15 at 19:01

1 Answers1

0

This answer and the answer below the selected answer in the question - in conjunction - saved my behind and made everything work swimmingly! Very grateful I stumbled over this.

How to re-create database for Entity Framework?

Community
  • 1
  • 1
ObedMarsh
  • 433
  • 4
  • 19