stuart
stuart

Reputation:

asp.net redirect in firefox not working

In my .net 3.5 web app i redirect users to another page using response.redirect.

This works in all ie browsers but not in firefox browsers. i have no idea why?

Response.Redirect("~/"+ GlobalConsts.ARTICLE_ANALYSER_URL +"?"+ GlobalConsts.QUERYSTRING_KEY_ONE + 
            SessionHandler.RedirectToArticleID + GlobalConsts.QUERYSTRING_KEY_TWO + 
            SessionHandler.RedirectToArticleParentOrChild);

Upvotes: 3

Views: 4544

Answers (7)

flap13
flap13

Reputation: 411

try this: Response.RedirectPermanent(url, true);

Upvotes: -1

Markis
Markis

Reputation: 1813

Updated

Instead of using Response.Redirect just manually do the redirect:

Response.Clear();
Response.Status = "302 Found";
Response.StatusCode = 302;
Response.AddHeader("Location", url);
Context.ApplicationInstance.CompleteRequest();

Old Post

It might be a caching issue, as according to this article http://www.mrclay.org/2011/07/03/firefox-5-shibboleth-issues/

And you might need to remove any caching headers you are sending along in the response. So set the cache headers to not cache and then response redirect:

Response.Cache.SetCacheability(HttpCacheability.NoCache); 
Response.Redirect("~/"+ GlobalConsts.ARTICLE_ANALYSER_URL +"?"+ GlobalConsts.QUERYSTRING_KEY_ONE + 
            SessionHandler.RedirectToArticleID + GlobalConsts.QUERYSTRING_KEY_TWO + 
            SessionHandler.RedirectToArticleParentOrChild);

Upvotes: 1

user240141
user240141

Reputation:

Try this piece:

Response.Redirect("~/"+ GlobalConsts.ARTICLE_ANALYSER_URL +"?"+ GlobalConsts.QUERYSTRING_KEY_ONE + 
            SessionHandler.RedirectToArticleID + GlobalConsts.QUERYSTRING_KEY_TWO + 
            SessionHandler.RedirectToArticleParentOrChild,false);

Upvotes: 0

Nitin S
Nitin S

Reputation: 7591

you can create a javascript function and call it when redirection needs to be done,

//javascript
function RedirectJS(url){
    window.location.href=url;
}

in the codebehind modify the onclick attribute of the button

//C#
protected void Page_Load(object sender, EventArgs e)
{
     if(!IsPostBack)
     {
          Button1.OnClientClick = "RedirectJS('"+HttpContext.Current.Request.ApplicationPath+"/"+GlobalConsts.ARTICLE_ANALYSER_URL +"?"+ GlobalConsts.QUERYSTRING_KEY_ONE + SessionHandler.RedirectToArticleID + GlobalConsts.QUERYSTRING_KEY_TWO + SessionHandler.RedirectToArticleParentOrChild+"');";
     }
}

Upvotes: 0

eglasius
eglasius

Reputation: 36027

Always check with fiddler first.

I like a suggestion made in the forum you linked, about it not being an error with redirections, but an issue with the browser cache. Try setting the expires header.

If the above doesn't do it, share more of your findings with fiddler.

Upvotes: 3

Dan Herbert
Dan Herbert

Reputation: 103397

Try installing this Firefox extension and recording the headers that are sent to the client:

https://addons.mozilla.org/en-US/firefox/addon/3829

The headers may give you some more insight into what is going wrong.

Upvotes: 6

Alex
Alex

Reputation: 77329

In firefox, check your about:config setting network.http.redirection-limit (which should be greater than 1).

A quick hint for general development troubleshooting with FireFox: Get the Firebug extension.

Upvotes: 0

Related Questions