locked
Is a YSOD not an exception? RRS feed

  • Question

  • User-1484187403 posted

    I have this code in _PageStart.cshtml:

    @*This is from Brind's book p. 226*@
    @{
    try
    {
    RunPage();
    }
    catch (Exception ex)
    {
    var message = ex.Message + "\n";
    var stack = ex.StackTrace;
    
    var logentry = DateTime.Now + "\n" + message + stack;
    logentry += "\n===============================\n";
    var location = Server.MapPath("~/App_Data");
    const string filename = "myNextWinnerErrLog.txt";
    var path = Path.Combine(location, filename);
    File.AppendAllText(path, logentry);
    WebMail.Send("duckbilledPlatydude@att.net", "err in myNextWinner on" + DateTime.Now.ToLongDateString() + " at " + DateTime.Now.ToLongTimeString(), "the following err occurred\n" + message + stack,
    isBodyHtml: false
    );
    Response.Redirect("~/BooBoo/");
    }
    
    }

    ...but when I got YSODs because of some bad html that caused pages that should have loaded not to load (and instead show the YSODs), I did not get the "BooBoo" page, nor did I get an email or an err msg in my AppData folder. Why not?

    Thursday, August 29, 2013 1:02 AM

Answers

  • User-1484187403 posted

    It compiles; this is a live site. It turned out it was deployed to the wrong spot (in a "/myapp" subfolder). The err was because it was trying to load json files that it couldn't see. Now that that problem has been cleared up, they load just fine (http://awardwinnersonly.com)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 30, 2013 12:21 AM

All replies

  • User197322208 posted

    Maybe you have an error in catch code. What the YSOD said about error?

    Thursday, August 29, 2013 1:51 AM
  • User-1484187403 posted

    This was the YSOD (it's fixed now - I had some bogus html, but I'd still like to know why my "BooBoo.cshtml" page didn't display, or I didn't get an email of the err msg in my App_Data folder:

    Server Error in '/' Application.


    Runtime Error

    Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 

    Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

    <!-- Web.Config Configuration File -->
    
    <configuration>
        <system.web>
            <customErrors mode="Off"/>
        </system.web>
    </configuration>

    Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

    <!-- Web.Config Configuration File -->
    
    <configuration>
        <system.web>
            <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
        </system.web>
    </configuration>
    Thursday, August 29, 2013 4:08 AM
  • User197322208 posted

    put

    <customErrors mode="Off"/>

    and retry

    Thursday, August 29, 2013 4:59 AM
  • User-821857111 posted

    If the error is a compiler error, the site won't even load and the error handling you have applied won't be reached. Once you have followed Andrei's advice, you can tell us what the actual error message is.

    Thursday, August 29, 2013 5:57 AM
  • User-1484187403 posted

    It compiles; this is a live site. It turned out it was deployed to the wrong spot (in a "/myapp" subfolder). The err was because it was trying to load json files that it couldn't see. Now that that problem has been cleared up, they load just fine (http://awardwinnersonly.com)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 30, 2013 12:21 AM