Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Deployment > Setting DefaultRedirect for customErrors

Setting DefaultRedirect for customErrors

  • Kostadinka avatar

    Posted on Jan 26, 2011 (permalink)

    Hi,

    I'm trying to set a default web page for errors in my site. I wrote this in my web.config:

    <

     

    customErrors defaultRedirect="~/ErrorPage.aspx" mode="RemoteOnly">

     

    <

     

    error redirect="~/Sitefinity/nopermissions.aspx" statusCode="403"/>

     

    </

     

    customErrors>

    I set a wrong connectionstring for one of my data sources, and I ran it from other machine. The result is that the page is steal and there is not a redirection.

    After that I set mode="On" and debug it. The error has occurred and the site is steal.

    I set the following in the Global.asax it works properly - shows the custom error page.

     

    void Application_Error(object sender, EventArgs e) 
      {
          // DONE IN WEB.CONFIG
            
          Exception ex = Server.GetLastError();
          if (ex is HttpException)
          {
              HttpException httpEx = ex as HttpException;
              if (httpEx.ErrorCode == 403 || httpEx.Source.StartsWith("Telerik.Cms"))
              {
                  Response.Redirect("~/Sitefinity/nopermissions.aspx");
                  Server.ClearError();
              }
              else
              {
                  Response.Redirect("~/ErrorPage.aspx");
                  Server.ClearError();
              }
          }
          else if (ex is Telerik.Security.SecurityApplicationException)
          {
              Response.Redirect("~/Sitefinity/nopermissions.aspx");
              Server.ClearError();
          }
           
      }

    But I'd like to use the web.config for that because I want to set mode to RemoteOnly and I want to manipulate its value.

    Do you have any advices?

    I have Sitefinity 3.7.
    My Error page has no code behind.

    Regards,
    Kostadinka

    Reply

  • Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Jan 31, 2011 (permalink)

    Hi Kostadinka,

    Thank you for using our services.

    Can you please breakpoint your code in Global.asax and see what is the status code of the error? Then try providing a redirect rule for this particular error code.

    Greetings,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Kostadinka avatar

    Posted on Jan 31, 2011 (permalink)

    The error code is 401. It works when I use Global.asax code, but it doesn't If I use the web.config settings (the DefaultRedirect).

    Reply

  • Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Feb 1, 2011 (permalink)

    Hello Kostadinka,

    Can you please try setting an error redirect for 401 in custom errors, instead of default redirect?

    All the best,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Kostadinka avatar

    Posted on Feb 1, 2011 (permalink)

    Yes, the custom redirect works, but the default - does not. So, do I have to set a custom error for everything?
    The error 401 was simulated by me to test error page redirecting.

    Reply

  • Vickie avatar

    Posted on Feb 2, 2012 (permalink)

    I updated my Fire Fox and it has a run time error. It said to set defaultRedirect for custom errors. I am not sure what to do.

    Reply

  • Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Feb 6, 2012 (permalink)

    Hi,

    If your website is running on IIS 7.0 or later you can use the httpErrors configuration:
    <httpErrors errorMode="Custom">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="/error-pages/404" responseMode="ExecuteURL" />
            <remove statusCode="500" subStatusCode="-1" />
            <error statusCode="500" prefixLanguageFilePath="" path="/error-pages/default" responseMode="ExecuteURL" />
        </httpErrors>


    Regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Register for webinar
Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Deployment > Setting DefaultRedirect for customErrors