Solved

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

Posted on 2009-01-27
39,024 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. Privacy Policy Terms of Use

    Featured Post

    Learn The Basics of Ethical Hacking & Pen Testing

    Computer and network security is one of the fastest growing and most essential industries in technology, meaning companies will pay big bucks for ethical hackers. This is the perfect course to leap into this lucrative career, learning how to use ethical hacking to reveal ...

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.

    679 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

    37 Experts available now in Live!

    Get 1:1 Help Now