3

I have created an MVC3 application and added cutomerrors attribute on in web.config. It works in chrome and Firefox but When I run it in IE9, I get

The website cannot display the page

HTTP 500

Most likely causes: •The website is under maintenance. •The website has a programming error.

What you can try:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->

<configuration>
  <appSettings>
    <add key="ClientValidationEnabled" value="true"/> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/> 
  </appSettings>

  <system.web>
      <customErrors mode="On"></customErrors>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>

    <authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" 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>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

2 Answers 2

3

There is a known problem in Internet Explorer versions where a custom error page has to be at least 512 bytes. While this usually applies to old IE versions and usually resulting in a 404 error page, I'd recommend to ensure that your custom error page is, say 1 kB of size. You might put some HTML comments in or something. Just to ensure that it has nothing to do with that old IE bug.

Just one reference of many: http://perishablepress.com/press/2008/01/21/important-note-for-your-custom-error-pages/

Sign up to request clarification or add additional context in comments.

3 Comments

thanks it worked. One issue however is that as I am using VS developement server. so when I run my MVC application, It hits the place where exception has occurred in controller and then I press enter to show error page. can't It go directly to error page ?
what do you mean with "it hits the place"? Do you mean VS holds in debugger? If so, you might use your Visual Studio Main Menu "Debug" » "Exceptions..." and there you can setup which exceptions you want to handle, this might help. For more control, you might look here: stackoverflow.com/questions/183316/asp-net-mvc-handleerror/… (But this is another story)
Thanks! After countless hours of trying to figure it out... Gotta love IE. +1
0

That's the inbuilt IE error page. Can you post your web.config so we can see what you have in there?

<customErrors mode="On" defaultRedirect="/Home/Error">
  <error statusCode="403" redirect="/Home/NoAccess" />
  <error statusCode="404" redirect="/Home/NotFound" />
  <error statusCode="500" redirect="/Home/Internal" />
</customErrors>

Is what I'd expect to see in the web config. I'm not sure what page is being shown in the other browsers.

I guess IE9 is expecting some content to be returned, try adding the Internal action and view to your home controller and specifying defaultRedirect="/Home/Internal" and see if that works.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.