+1-888-365-2779
Try Now
More in this section

Forums / Deployment / Setting DefaultRedirect for customErrors

Setting DefaultRedirect for customErrors

7 posts, 0 answered
  1. Kostadinka
    Kostadinka avatar
    16 posts
    Registered:
    27 Jul 2010
    26 Jan 2011
    Link to this post

    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

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    31 Jan 2011
    Link to this post
    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
  3. Kostadinka
    Kostadinka avatar
    16 posts
    Registered:
    27 Jul 2010
    31 Jan 2011
    Link to this post
    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).
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    01 Feb 2011
    Link to this post
    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
  5. Kostadinka
    Kostadinka avatar
    16 posts
    Registered:
    27 Jul 2010
    01 Feb 2011
    Link to this post
    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.
  6. Vickie
    Vickie avatar
    1 posts
    Registered:
    02 Feb 2012
    02 Feb 2012
    Link to this post
    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.
  7. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    06 Feb 2012
    Link to this post
    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
Register for webinar
7 posts, 0 answered