CustomErrors section

Last post 05-09-2008 1:11 PM by ksrao720@yahoo.com. 17 replies.

Sort Posts:

  • CustomErrors section

    05-05-2008, 1:03 PM

    HI,

    In my Application I want to handle the 404 error.

    If the requested url doen not have .aspx extension can we handle that error. I am able to handle the 404 error if the url has .aspx extension.

    I want to handle that error in all the cases(for any kind of page like .htm,.asp,etc)is it possible?

  • Re: CustomErrors section

    05-05-2008, 1:15 PM

    put this in web.config'

    <customErrors mode = "On">

    <error statusCode = "404" redirect = "errorPage.aspx" />

    </customErrors>

     make sure you have errorPage.aspx in your directory.

    hope it helps.
     

     

    Hope it helps.

    -Manas
  • Re: CustomErrors section

    05-05-2008, 1:20 PM

    I did that, errorPage.aspx is handling the error if the request has only .aspx extension.  if the request has default.htm then errorPage.aspx is not handling the error? I want the errorPage.aspx to handle that also. can we do that?

    thanks

  • Re: CustomErrors section

    05-05-2008, 1:27 PM

           try
            {
                Response.Redirect("default.html");
            }
            catch
            {
                Response.Redirect("err.aspx");
            }

    hope it helps. 

    Hope it helps.

    -Manas
  • Re: CustomErrors section

    05-05-2008, 1:28 PM
    I am sorry to ask you,where I need to put that code
  • Re: CustomErrors section

    05-05-2008, 1:35 PM

    Its clear from the code man. Where ever you are redirecting the user to different page as-

    Response.Redirect("default.html");

    put this in try block as

    try

    {

    Response.Redirect("default.html");

     

    and put a catch block to handle that as -

    catch

    {

    response.redirect("err.aspx");

    }

    you can see the full code in previous post. the page u r redirecting is

    default.html.

    Mark as answer if this post helps you.

     

    Hope it helps.

    -Manas
  • Re: CustomErrors section

    05-05-2008, 1:44 PM

    url------www.aaa.com/Register.aspx  if user enters this in the browser if my site does not have Register.aspx then control goes to ErrorPage.aspx.

    like that www.aaa.com/defualt.htm-----if user enters this in the browser, user will get page not found error if my site does not have default.htm.

    I am asking like is there any way to handle that error in my page?

  • Re: CustomErrors section

    05-05-2008, 1:48 PM

     custom error setting will automatically handle this. I cant understand where is the problem.

     just put the code in first post in web config.
     

    Hope it helps.

    -Manas
  • Re: CustomErrors section

    05-05-2008, 1:52 PM
    <customErrors mode="Off" defaultRedirect="Err.aspx">

    <error statusCode="404" redirect="Err.aspx" />

    </customErrors >

    Even I thought like that. but above code is only handling the error if the page has .aspx extension. 

     

  • Re: CustomErrors section

    05-05-2008, 1:53 PM
    <customErrors mode="On" defaultRedirect="Err.aspx">

    <error statusCode="404" redirect="Err.aspx" />

    </customErrors >

     

    this is my web.config code.

  • Re: CustomErrors section

    05-05-2008, 2:02 PM

    ksrao720@yahoo.com:
    <customErrors mode="On" defaultRedirect="Err.aspx">

    <error statusCode="404" redirect="Err.aspx" />

    </customErrors >

     

     

     

    when you handle error indivisually in web.config, may be you have to put different pages for different errors.

    try -

    <customErrors mode = "On" defaultRedirect="err.aspx">

    <error statusCode = "404" redirect = "errorPage.aspx" />

    </customErrors>

     

    note err.aspx n errorPage.aspx are different.

    hope it helps. 

     

    Hope it helps.

    -Manas
  • Re: CustomErrors section

    05-05-2008, 2:07 PM

    no use yeotumitsu. I tried that.

    Thanks

  • Re: CustomErrors section

    05-05-2008, 2:11 PM

     you are missing something for sure.

      this is a working code in my application.

    ////////////////////////////////////////

    <customErrors mode = "On">

          <error statusCode = "404" redirect = "err.aspx" />

     </customErrors>

    //////////////////////////////////////

    best of luck. 
     

    Hope it helps.

    -Manas
  • Re: CustomErrors section

    05-05-2008, 2:17 PM

    For some reason it's not working for me. I mean it is working if I request for something that contains .aspx extension. It's not working if i give something leke default.htm.

    anyway thanks for your patience, 

     

  • Re: CustomErrors section

    05-05-2008, 2:20 PM

     last try -

     put it like this dont write default redirect.

    /////////////////////////////////////////////// 

    <customErrors mode = "On">  --->> dont put default redirect here.

          <error statusCode = "404" redirect = "err.aspx" />

     </customErrors>

    //////////////////////////////////////////////

    hope it helps. 

    Hope it helps.

    -Manas
Page 1 of 2 (18 items) 1 2 Next >