How can I get customErrors' defaultRedirect value from code?

.net, asp.net-mvc, c#, custom-errors, web-config

Solution

Thanx mark, it was helpful. What I really wanted to ask was "how to get "defaultRedirect" property of customErrors section from web.config of my asp mvc app?".

And the answer, based on your post is:

    CustomErrorsSection customErrorsSection = (CustomErrorsSection) ConfigurationManager.GetSection("system.web/customErrors");
        string defaultRedirect = customErrorsSection.DefaultRedirect;

Problem

I would simply like to do something as follows: ``` var defaultRedirectUrl = SomeMethodToGetDefaultRedirect(); ``` of course in web.config I have ``` <customErrors mode="On" defaultRedirect="~/Error"/> ``` How to do this?

Original source