List Info

Thread: Response.Redirect not working with IE in Internet Zone




Response.Redirect not working with IE in Internet Zone
user name
2006-04-27 14:29:57
I have had sporadic problems over the years using
Response.Redirect()
especially if there is any sort of volume on the website. I
don't know
if I ever got this specific problem or not, but I have had a
lot of
complaints about user's receiving Object Moved screens
instead of being
correctly redirected.  What I ended up doing that has helped
a lot (zero
redirect complaints after implementation) was to write my
own redirect
method which you can call instead of response.redirect().  I
found this
after hours of googling, and maybe it will help you save
some time.  It
has the same signature, so you just need to create it as a
static method
in some class that your pages can access.

/// <summary>
/// Performs a redirect to the specified page.
/// </summary>
/// <param name="newLocation">Name of page
to redirect user to</param>
/// <param name="endResponse">Indicates if
the Redirect should end the
response stream</param>
public static void RedirectUrl(string newLocation, bool
endResponse)
{
        System.Web.HttpContext.Current.Response.Expires = 0;
        System.Web.HttpContext.Current.Response.Buffer  =
true;
        System.Web.HttpContext.Current.Response.Clear();
       
System.Web.HttpContext.Current.Response.AddHeader("Loc
ation",
newLocation);
       
System.Web.HttpContext.Current.Response.Write("<MET
A
HTTP-EQUIV=Refresh CONTENT=\"0;URL=" +
newLocation + "\">");

        if (endResponse)
               
System.Web.HttpContext.Current.Response.End();
}

/// <summary>
/// Performs a redirect to the specified page.
/// </summary>
/// <param name="newLocation">Name of page
to redirect user to</param>
public static void RedirectUrl(string newLocation)
{
        RedirectUrl(newLocation, true);
}

Good Luck!
MK


-----Original Message-----
From: Discussion of building .NET applications targeted for
the Web
[mailtoOTNET-WE
BDISCUSS.DEVELOP.COM] On Behalf Of Shawn Wildermuth
Sent: Wednesday, April 26, 2006 9:40 PM
To: DOTNET-WEBDISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] Response.Redirect not working with
IE in
Internet Zone

So if it failing with a ? In the url, could you give us a
couple of
examples
of what those look like.  Do the relative paths include
locational
information (e.g. ./default.aspx instead of default.aspx)?




Thanks,

Shawn Wildermuth
http://adoguy.com
C# MVP, MCSD.NET, Author and Speaker


-----Original Message-----
From: Discussion of building .NET applications targeted for
the Web
[mailtoOTNET-WE
BDISCUSS.DEVELOP.COM] On Behalf Of Pete Moss
Sent: Wednesday, April 26, 2006 9:30 PM
To: DOTNET-WEBDISCUSS.DEVELOP.COM
Subject: [DOTNET-WEB] Response.Redirect not working with IE
in Internet
Zone

I have an odd problem in my application when I use
Response.Redirect(url,
false) where url is a relative URL. Everything is fine if
the app is
running
in the Intranet Zone, but when I switch to running in the
Internet Zone,
the
Response.Redirect() does nothing in an IE browser. It works
fine in
Firefox,
though!

It works most of the time if there are no URL-encoded
parameters, but
never
works if there is something following following a '?' in
the URL. I have
found 18 of the 20 cases with no parameters where it works.
I can't
understand why those other 2 don't work.

Does anyone know why this could be happening? I did see in
the
Response.Redirect() doc the following line:

An absolute URL (for example, http://www.contos
o.com/default.aspx) or a
relative URL (for example, default.aspx) can be specified
for the target
location but some browsers may reject a relative URL.

I wonder if the "some browsers may reject a relative
URL" may be what is
causing me the problem. Is there an IE security setting that
might allow
this to work?

===================================
This list is hosted by DevelopMentorR  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )