Solved

<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> tag

Posted on 2009-01-27
39,203 Views
1 Ratings
Last Modified: 2012-05-06
Hi, I need to know the details of the errors that I get, I put <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
 but when the error appears the page redirects to mycustompage.htm but there is no error details appear, what should I do in mycustompage.htm page to show the details of the error?
1
Question by:Abdu_Allah
    13 Comments
     
    LVL 53

    Accepted Solution

    by:
    0
     
    LVL 12

    Assisted Solution

    by:CB_Thirumalai
    mycustompage.htm is just a friendly page wherein you can say the user that an error has occurred.  But in order to catch the error and do some processing, you may need to use the Application_Error, which is part of the Global.asax and handle the error.
    void Application_Error(object sender, EventArgs e) 
    
    { 
    
        // Code that runs when an unhandled error occurs
    
        // Server.GetLastError() is the entire exception object that you can use.
    
    }
    

    Open in new window

    0
     
    LVL 6

    Expert Comment

    by:sankar_ravi
    Hi
    Make sure that, your web.config has this much only i.e., <customErrors mode="RemoteOnly"/>
    Results of this is that if you know the scenario to reproduce, you will be able to see the complete error details when you run the app in local web server.  You will never get detailed error when you access remotely with this configuration.

    Irrespctive of end user or service provider wants to see the complete error, then use <customError mode="On"/>

    In case you don't want your customers to see the errors, then use Page_Error event on all webpages and try to redirect the user to the mycustompage.htm. example:
    private void Page_Error(object sender, System.EventArgs e)
    {
    }
    Hope this helps.
    Thanks,
    Ravi
    0
     
    LVL 6

    Expert Comment

    by:sankar_ravi
    In my above comment, i just forgot one snippet in Page_Error event on all web pages
    Page_Error()
    {
    Exception errEx=Server.GetLastError();
    string errmessage= errEx.Message
    string stktrace= errEx.StackTrace
    Server.ClearError(); // Make sure to clear the error after usage.
    }
    0
     
    LVL 3

    Author Comment

    by:Abdu_Allah
    I guess I should write the error message errmessage before this statement: Server.ClearError();  
    right?
     
    0
     
    LVL 12

    Expert Comment

    by:CB_Thirumalai
    You mean display the message in the page, yes
    0
     
    LVL 3

    Author Comment

    by:Abdu_Allah
    It does not show any error!
    0
     
    LVL 3

    Author Comment

    by:Abdu_Allah
    CB_Theromalia, how can I display the error message in the customerror.htm file When I use Application_Error event that found in global.asax file?!
    0
     
    LVL 12

    Expert Comment

    by:CB_Thirumalai
    Ok, if you want to show the error, then do a Response.Write(errEx.ToString()); before Server.ClearError();
    0
     
    LVL 3

    Author Comment

    by:Abdu_Allah
    Do that in global.asax file! this is not possible!
    0
     
    LVL 12

    Expert Comment

    by:CB_Thirumalai
    I have not said it to write that in global.asax, but in the page where you are catching the error, as said by sankar_ravi.
    0
     
    LVL 3

    Author Comment

    by:Abdu_Allah
    I get the following error although the system successfully redirect to my error.aspx page!
     
      Server Error in '/demo' 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>
    1
     

    Expert Comment

    by:snyderkv
    After turrning custom errors off as described above, I was able to see the FIPS was my issue. Some new 2008 security feature. Turned it off and rebooted. The website works.

    Thanks
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now