Answered Internal Server Error

  • Wednesday, August 08, 2012 2:43 PM
     
      Has Code

    When I deploy a Asp.Net MVC 4 project on a Windows Azure Web Site, i got an error : "Internal Server Error". Here is some information:

    URL: http://jobhunting.azurewebsites.net/Test

    Code:

    public class WebApiApplication : System.Web.HttpApplication
        {
            protected void Application_Start()
            {
                RouteConfig.RegisterRoutes(RouteTable.Routes);
            }
        }
    
    
    public class RouteConfig
        {
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                );
    
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );
            }
        }

    public class TestController : ApiController
        {
            public string Get()
            {
                return "Hello world!";
            }
        }
    Requst:
    GET http://jobhunting.azurewebsites.net/Test HTTP/1.1
    User-Agent: Fiddler
    Host: jobhunting.azurewebsites.net
    
    Response:
    HTTP/1.1 500 Internal Server Error
    Cache-Control: no-cache
    Pragma: no-cache
    Content-Length: 0
    Expires: -1
    Server: Microsoft-IIS/7.5
    Set-Cookie: ARRAffinity=a6aec26b7781cb8e149d2231a6c9598687a9317297711bb1b977bb5ecc57e13a;Path=/;Domain=jobhunting.azurewebsites.net
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    X-Powered-By: ARR/2.5
    X-Powered-By: ASP.NET
    Date: Wed, 08 Aug 2012 13:23:32 GMT
    

    Request Diagnostics file:

    http://jobhunting.azurewebsites.net/fr000015.xml

    I would truly appreciate any guidance I can get on this.
    Thanks!

    快乐在于能够长时间的为自己认为值得的事情努力工作,不管它是什么。

All Replies

  • Thursday, August 09, 2012 4:01 AM
    Moderator
     
      Has Code

    Hi,

    Can you make sure the MVC assemblies has been set copy to local property with "True" in MVC 4 website application? And i'd like to suggest you set debug to ture to collect more information about the exception. The configuration will be like this:

    <compilation debug="true"/> 
    

    In addition, Do you enable .NET 4.5 or .NET 4.0 for MVC web application? Would you like to check the target frameworks version with web config file?

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

  • Thursday, August 09, 2012 4:43 AM
     
      Has Code

    Thanks, Arwind.

     I‘ve done as you said.  but the problem is still.


    assemblies:

    2012-07-09  15:32           105,536 Antlr3.Runtime.dll
    2012-07-09  15:31         1,111,640 EntityFramework.dll
    2012-03-16  15:00           133,120 HtmlAgilityPack.dll
    2012-05-24  18:09           334,648 Microsoft.Practices.EnterpriseLibrary.Common.dll
    2012-05-24  18:09           502,584 Microsoft.Practices.EnterpriseLibrary.Logging.dll
    2012-05-24  18:09            29,760 Microsoft.Practices.ServiceLocation.dll
    2012-05-24  18:09            86,840 Microsoft.Practices.Unity.Configuration.dll
    2012-05-24  18:09           124,216 Microsoft.Practices.Unity.dll
    2012-05-24  18:09            35,640 Microsoft.Practices.Unity.Interception.Configuration.dll
    2012-05-24  18:09           120,632 Microsoft.Practices.Unity.Interception.dll
    2012-03-14  18:15            45,416 Microsoft.Web.Infrastructure.dll
    2012-07-21  09:35            17,520 Microsoft.WindowsAzure.Configuration.dll
    2012-06-02  17:54           323,320 Microsoft.WindowsAzure.Diagnostics.dll
    2012-07-21  09:35           368,376 Microsoft.WindowsAzure.StorageClient.dll
    2012-07-09  15:32           368,128 Newtonsoft.Json.dll
    2012-07-09  15:32           181,856 System.Net.Http.dll
    2012-07-09  15:32           159,328 System.Net.Http.Formatting.dll
    2012-07-09  15:32            15,456 System.Net.Http.WebRequest.dll
    2012-07-09  15:32           138,352 System.Web.Helpers.dll
    2012-07-09  15:32           360,032 System.Web.Http.dll
    2012-07-09  15:32            65,632 System.Web.Http.WebHost.dll
    2012-07-09  15:32           497,248 System.Web.Mvc.dll
    2012-07-09  15:32            50,304 System.Web.Optimization.dll
    2012-07-09  15:32           269,120 System.Web.Providers.dll
    2012-07-09  15:32           264,816 System.Web.Razor.dll
    2012-07-09  15:32            40,560 System.Web.WebPages.Deployment.dll
    2012-07-09  15:32           204,400 System.Web.WebPages.dll
    2012-07-09  15:32            39,536 System.Web.WebPages.Razor.dll
    2012-07-09  15:32           860,736 WebGrease.dll

    Web.config :

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <configSections>
      </configSections>
      <connectionStrings>
      </connectionStrings>
      <appSettings>
        <add key="webpages:Version" value="2.0.0.0" />
        <add key="webpages:Enabled" value="true" />
        <add key="PreserveLoginUrl" value="true" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
      </appSettings>
      <system.web>
        <customErrors mode="Off" />
        <compilation debug="true" targetFramework="4.0" />
        <authentication mode="Forms">
          <forms loginUrl="~/Account/Login" timeout="2880" />
        </authentication>
        <pages>
          <namespaces>
            <add namespace="System.Web.Helpers" />
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
            <add namespace="System.Web.WebPages" />
          </namespaces>
        </pages>
        <profile defaultProvider="DefaultProfileProvider">
          <providers>
            <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
          </providers>
        </profile>
        <membership defaultProvider="DefaultMembershipProvider">
          <providers>
            <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
          </providers>
        </membership>
        <roleManager defaultProvider="DefaultRoleProvider">
          <providers>
            <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
          </providers>
        </roleManager>
        <sessionState mode="InProc" customProvider="DefaultSessionProvider">
          <providers>
            <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
          </providers>
        </sessionState>
      </system.web>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true" />
        <handlers>
          <remove name="ExtensionlessUrl-Integrated-4.0" />
          <add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,DELETE,PUT" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
      </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-2.0.0.0" newVersion="2.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>



    快乐在于能够长时间的为自己认为值得的事情努力工作,不管它是什么。

  • Thursday, August 09, 2012 6:49 AM
    Moderator
     
     

    Hi,

    Cant you got more details about that exception? (include event logs, stack, trace, etc), 500 error maybe a very broad error message. You can set customErrors mode="On" .

    i note there's Microsoft.Practices.EnterpriseLibrary assembly in your list,  please let me know the version of the Enterprise Library you're using. The lastest version is here:

    http://www.microsoft.com/en-ca/download/details.aspx?id=6836 

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework


  • Thursday, August 09, 2012 9:32 AM
     
     

    Thanks, Arwind.

    There's no more detailed exception information, because server http response has head but no body.
    Microsoft.Practices.EnterpriseLibrary should be the latest version,is 5.0.505.0.



    快乐在于能够长时间的为自己认为值得的事情努力工作,不管它是什么。

  • Thursday, August 09, 2012 1:21 PM
     
     

    Why dont you enable intelli trace and check whats going on?

    Please go through this



    Please mark the replies as Answered if they help and Vote if you found them helpful.

  • Thursday, August 09, 2012 1:43 PM
     
     

    Thanks,Veerendra Kumar.

    Will Intelli Trace work well on Windows Azure Web Site environment?


    快乐在于能够长时间的为自己认为值得的事情努力工作,不管它是什么。

  • Friday, August 10, 2012 2:49 AM
    Moderator
     
     

    Hi,

    Yes, As I was mentioned above, 500 error maybe a very broad error message, we can not make sure where the exception was thrown, so i think you need post them first. The configurations and code looks no propblem.

    BR,

    Arwind


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

  • Friday, August 10, 2012 4:23 AM
     
     
    Yes, As metioned by Arwing and me, to trace what problem is exactly causing 500 error, you can enable intelli trace. The link in my previous post helps you to understand how to achieve it.


    Please mark the replies as Answered if they help and Vote if you found them helpful.

  • Friday, August 10, 2012 1:54 PM
     
     Answered
    Hi Arwind,

    I know the 500 error is a very broad error message, but the response from the server does only this, there is no more detailed exception, because the http response is the only head, but not the body!

    Hi Veerendra Kumar,

    I find on the Internet, intelli trace is not used in the windows azure web site (not a cloud service), if you know how to turn on, please tell me, thank you.



    I solved my problem, by re-create my Asp.Net mvc web api project, the cause of the problem may be because my project is upgrade from Asp.Net mvc 4 beta.

    快乐在于能够长时间的为自己认为值得的事情努力工作,不管它是什么。

    • Marked As Answer by 温海雄 Friday, August 10, 2012 1:55 PM
    •