custom 404 page works in IE but not firefox

Discussion in 'ASP General' started by c676228, Apr 3, 2008.

  1. c676228

    c676228 Guest

    Hi all,

    A couple of months ago. I posted a thread and asked for help for redirect
    all our site *.htm pages to *.asp pages because of our site upgrade almost
    all *.htm to *.asp.
    So some community members suggested use custom error page and redirect the
    page to the same file but different ext. *.asp and it works fine in IE. But
    when we tested in firefox today. it is not working. I wonder why? It is
    because firefox return different format qstr? can you give me some clue. How
    can I display the qstr in broswer in order to investigate it?
    here is the code:

    <% ' vbs
    qstr = Request.ServerVariables("QUERY_STRING")

    If instr(lcase(qstr),".htm")>0 then
    on error resume next
    x = replace(qstr, "404;http://www.mydomain.com:80","")
    '404;http://www.mydomain.com:80
    x = replace(x,".htm",".asp")

    'server.transfer x
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", x
    'Response.Redirect x

    on error resume next
    Response.Redirect "http://www.mydomain.com/404Page.htm"
    on error goto 0
    Else
    on error resume next
    Response.Redirect "http://www.mydomain.com/404Page.htm"
    End if
    %>
    --
    Betty
    c676228, Apr 3, 2008
    #1
    1. Advertising

  2. Hi Betty,

    In the script code you posted:

    ============
    on error resume next
    x = replace(qstr, "404;http://www.mydomain.com:80","")
    '404;http://www.mydomain.com:80
    x = replace(x,".htm",".asp")

    'server.transfer x
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", x
    'Response.Redirect x

    on error resume next
    Response.Redirect "http://www.mydomain.com/404Page.htm"
    on error goto 0
    ==============

    I think as long as you add the code to set response status(to 301) and the
    new location, you can end the response. However, you still called another
    Response.Redirect, is this your original code logic? Or is the following
    code is necessary?

    ============
    x = replace(qstr, "404;http://www.mydomain.com:80","")

    x = replace(x,".htm",".asp")

    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", x
    ============

    I've tested in my local box with Firefox browser, seem it can correctly
    perform the redirection.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.


    This posting is provided "AS IS" with no warranties, and confers no rights.






    --------------------
    >From: =?Utf-8?B?YzY3NjIyOA==?= <>
    >Subject: custom 404 page works in IE but not firefox
    >Date: Wed, 2 Apr 2008 16:24:00 -0700
    >
    >Hi all,
    >
    >A couple of months ago. I posted a thread and asked for help for redirect
    >all our site *.htm pages to *.asp pages because of our site upgrade almost
    >all *.htm to *.asp.
    >So some community members suggested use custom error page and redirect the
    >page to the same file but different ext. *.asp and it works fine in IE.

    But
    >when we tested in firefox today. it is not working. I wonder why? It is
    >because firefox return different format qstr? can you give me some clue.

    How
    >can I display the qstr in broswer in order to investigate it?
    >here is the code:
    >
    ><% ' vbs
    >qstr = Request.ServerVariables("QUERY_STRING")
    >
    >If instr(lcase(qstr),".htm")>0 then
    > on error resume next
    > x = replace(qstr, "404;http://www.mydomain.com:80","")
    >'404;http://www.mydomain.com:80
    > x = replace(x,".htm",".asp")
    >
    > 'server.transfer x
    > Response.Status="301 Moved Permanently"
    > Response.AddHeader "Location", x
    > 'Response.Redirect x
    >
    > on error resume next
    > Response.Redirect "http://www.mydomain.com/404Page.htm"
    > on error goto 0
    >Else
    > on error resume next
    > Response.Redirect "http://www.mydomain.com/404Page.htm"
    >End if
    >%>
    >--
    >Betty
    >
    Steven Cheng [MSFT], Apr 3, 2008
    #2
    1. Advertising

  3. c676228

    Evertjan. Guest

    Steven Cheng [MSFT] wrote on 03 apr 2008 in
    microsoft.public.inetserver.asp.general:

    > ============
    > x = replace(qstr, "404;http://www.mydomain.com:80","")
    > x = replace(x,".htm",".asp")
    > Response.Status="301 Moved Permanently"
    > Response.AddHeader "Location", x
    > ============
    >


    But what would happen, Steven,
    if I requested a nonexisting page?

    An infinite loop? No nornmal 404 warning?

    Try this:
    [Nonexisting .asp versions wil be flagged,
    in the second redirect to the 404.asp]

    ============

    if lcase(right(qstr,4) = ".htm" then
    x = replace(qstr, "404;http://www.mydomain.com:80","")
    x = replace(x,".htm",".asp")
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", x
    Response.End
    end if
    %>
    This is the 404 page.
    <br>
    We are so sorry for you.
    <br>
    The requested page <%=qstr%> does not exist.

    ============

    Even then the acting on the default file of the root
    and other directories should be considered and changed.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Apr 3, 2008
    #3
  4. c676228

    c676228 Guest

    thanks Evertjan and Steven.
    I got it. It seems that on error resume next really messed up something.
    that's really a big from you guys and because of my predefined launch day
    tomorrow.

    :=) thanks thanks.
    --
    Betty


    "Evertjan." wrote:

    > Steven Cheng [MSFT] wrote on 03 apr 2008 in
    > microsoft.public.inetserver.asp.general:
    >
    > > ============
    > > x = replace(qstr, "404;http://www.mydomain.com:80","")
    > > x = replace(x,".htm",".asp")
    > > Response.Status="301 Moved Permanently"
    > > Response.AddHeader "Location", x
    > > ============
    > >

    >
    > But what would happen, Steven,
    > if I requested a nonexisting page?
    >
    > An infinite loop? No nornmal 404 warning?
    >
    > Try this:
    > [Nonexisting .asp versions wil be flagged,
    > in the second redirect to the 404.asp]
    >
    > ============
    >
    > if lcase(right(qstr,4) = ".htm" then
    > x = replace(qstr, "404;http://www.mydomain.com:80","")
    > x = replace(x,".htm",".asp")
    > Response.Status="301 Moved Permanently"
    > Response.AddHeader "Location", x
    > Response.End
    > end if
    > %>
    > This is the 404 page.
    > <br>
    > We are so sorry for you.
    > <br>
    > The requested page <%=qstr%> does not exist.
    >
    > ============
    >
    > Even then the acting on the default file of the root
    > and other directories should be considered and changed.
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
    >
    c676228, Apr 4, 2008
    #4
  5. Hi Betty,

    Really glad that it works for you.

    Have a nice launch day!

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    This posting is provided "AS IS" with no warranties, and confers no rights.


    --------------------
    >From: =?Utf-8?B?YzY3NjIyOA==?= <>
    >References: <>

    <j$>
    <Xns9A759F1F66D1Feejj99@194.109.133.242>
    >Subject: RE: custom 404 page works in IE but not firefox
    >Date: Thu, 3 Apr 2008 22:49:00 -0700


    >thanks Evertjan and Steven.
    >I got it. It seems that on error resume next really messed up something.
    >that's really a big from you guys and because of my predefined launch day
    >tomorrow.
    >
    >:=) thanks thanks.
    >--
    >Betty
    >
    >
    >"Evertjan." wrote:
    >
    >> Steven Cheng [MSFT] wrote on 03 apr 2008 in
    >> microsoft.public.inetserver.asp.general:
    >>
    >> > ============
    >> > x = replace(qstr, "404;http://www.mydomain.com:80","")
    >> > x = replace(x,".htm",".asp")
    >> > Response.Status="301 Moved Permanently"
    >> > Response.AddHeader "Location", x
    >> > ============
    >> >

    >>
    >> But what would happen, Steven,
    >> if I requested a nonexisting page?
    >>
    >> An infinite loop? No nornmal 404 warning?
    >>
    >> Try this:
    >> [Nonexisting .asp versions wil be flagged,
    >> in the second redirect to the 404.asp]
    >>
    >> ============
    >>
    >> if lcase(right(qstr,4) = ".htm" then
    >> x = replace(qstr, "404;http://www.mydomain.com:80","")
    >> x = replace(x,".htm",".asp")
    >> Response.Status="301 Moved Permanently"
    >> Response.AddHeader "Location", x
    >> Response.End
    >> end if
    >> %>
    >> This is the 404 page.
    >> <br>
    >> We are so sorry for you.
    >> <br>
    >> The requested page <%=qstr%> does not exist.
    >>
    >> ============
    >>
    >> Even then the acting on the default file of the root
    >> and other directories should be considered and changed.
    >>
    >> --
    >> Evertjan.
    >> The Netherlands.
    >> (Please change the x'es to dots in my emailaddress)
    >>

    >
    Steven Cheng [MSFT], Apr 4, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jonathan Folland
    Replies:
    2
    Views:
    1,612
    Jonathan Folland
    Mar 17, 2005
  2. F. GEIGER
    Replies:
    3
    Views:
    756
    F. GEIGER
    Aug 6, 2004
  3. John Rebbeck

    Custom Server Control works on page but not User Control...why?

    John Rebbeck, Sep 16, 2003, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    182
    John Rebbeck
    Sep 17, 2003
  4. Dfenestr8
    Replies:
    4
    Views:
    163
    Fred Oz
    Feb 22, 2005
  5. Sujan
    Replies:
    1
    Views:
    123
Loading...

Share This Page