0

Edit: showed my exact web.config code.

I have a MVC3 project that works fine on my box, but when I upload it to the web server, it gives an error on a certain page. I am trying to determine the exact error, but it keeps redirecting to the "Error/ShowError" action. I tried modifying the web.config file to say showcustomerrors=false, but it still redirects. I really need to see the actual error in order to troubleshoot the problem.

In firebug, it shows that the error is a 500 internal server error. I haven't been able to get any more detailed than that.

Also, if I run the page from my local box, but use the remote database, I don't get an error. This makes me think it's related to directory permissions.

Here is in my web.config section:

<compilation debug="true" targetFramework="4.0">

Here is in my web.debug.config section:

<customErrors  mode="Off">

Thanks!

user1304444
  • 1,713
  • 3
  • 21
  • 38

3 Answers3

0

Turn off customErrors in web.config and you will be able to see what the error is. then fix it. Turn the Custom Error on

<customErrors defaultRedirect="Error.aspx" mode="Off"/>
Shyju
  • 214,206
  • 104
  • 411
  • 497
0

Here are the options you have for custom errors:

<customErrors defaultRedirect="url"
          mode="On|Off|RemoteOnly">
      <error. . ./>
</customErrors>

I think your issue is that you're using 'false' instead of 'Off'.

Good luck, hope this works for you.

Reference: MSDN link for CustomErrors section

Community
  • 1
  • 1
Chris
  • 6,272
  • 9
  • 35
  • 57
0

See if these changes will help.

<configuration>
    <system.webServer>
        <httpErrors errorMode="Detailed" />
    </system.webServer>
    <system.web>
        <customErrors mode="Off"/>
        <compilation debug="true"/>
    </system.web>
</configuration>

If not, make sure that AspNet is properly installed. C:\Windows\Microsoft.Net\Framework..\v.....\aspnet_regiis.exe -i

Edit: You can try to log the exception message using the following method in Global.asax.cs

protected void Application_Error(object sender, EventArgs e) {
    var exception = Server.GetLastError();
    // Log the exception
}

Edit:

Well, this will be a lot to do, but I suggest you to add Elmah to your project to log unhandled exceptions. See the first step on Logging in MVC Part 1- Elmah

Elmah is available on NuGet Gallery.

M. Mennan Kara
  • 10,072
  • 2
  • 35
  • 39
  • Tried this...still getting a generic "Sorry, an error occurred while processing your request" message. The page is hosted by DailyRazor, so I don't have control over AspNet, but I've never had a problem in that area before. – user1304444 Jul 30 '12 at 16:51
  • When does "Application_Error" fire? I tried to get it to save the error to mydatabase, but after hitting the error no row was added to my database. – user1304444 Jul 30 '12 at 17:33
  • It is raised when there is an unhandled exception. Maybe the error is related with database, try to log to file system. – M. Mennan Kara Jul 30 '12 at 17:39
  • The best I can tell, that event is not firing. I've tried writing the error to the database, to the file system (I think writing to the file system is causing the initial error), e-mailing it to myself, and even returning a ContentResult. None of them get the error infomation to me. – user1304444 Jul 30 '12 at 18:01
  • I had some of it in web.debug.config. Once I moved it all to web.config, it started giving me proper error messages. – user1304444 Jul 30 '12 at 20:30