Response.Redirect not working (I'm looking at you SmartNavigation)
Whew. It has been a crazy two weeks on this project, and it all culminated with a nasty error where Response.Redirect was on the fritz. This one tore me up before I was able to figure out what was going wrong.

Basically I was doing a Response.Redirect on a page, and in Dev and Test it worked like a charm. Even after I moved it to production it worked for a while. But then the horror occurred. The response redirect suddenly would simply post back to the same page - no redirect at all.

I was able to narrow it down to the response.redirect fairly quickly, but I assumed it wasn't playing nice with some server setting in Prod that wasn't switched on in Dev or Test.

Well - I am not entirely convinced that some switch in IIS didn't get flipped, but quite frankly going down that rabbit hole wasn't getting me anywhere, and the client was waiting.

So I looked at all the opages to see how this one differed. Turns out this page was the only one with SmartNavigation turned on. So I set SmartNavigation to false, and voila.

Hope this tip helps some frustrated soul out!

EDIT: I have learned more about this error. See here for details.

Comments

# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar I spent about three hours trying to figure out why my pages wouldn't redirect until I came across your post and voila, it works. However, I have some rather lengthy pages that I cannot break up into smaller ones. Do you have any idea how to implement smart navigation and still be able to redirect?
Left by Mischa Rihm on 9/24/2005 2:47 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Well - as to implementing smart Nav without using that switch - I dunno how that might be done.... But, it is likely done via Javascript somehow. So you might turn smart Nav on then look at the JS generated via a 'View Source'. Obviously, the JS would need serious tweaking, but that is how I would start.
Left by JT on 9/30/2005 2:53 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Hi Geek,
You have just saved my soul today as well...You are damn right
smart navigation is the root cause of misery....Thanks a Million Pal....

Regds,
Manikandan.N
Left by Manikandan.N on 10/17/2005 9:12 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar I'm having the same problem with redirect, but I didn't have SmartNavigation set. I tried implicitly setting SmartNav to "false", but no luck. If anyone else has anymore ideas, please post.
Left by JoDaCoda on 11/2/2005 12:45 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Thank you, thank you, thank you. I have a presenation to do and I couldn't get past this. Thanks again.
Left by Skittles on 11/5/2005 1:04 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Very helpful. Worked fine with aspnet 1.0 and VS 2002. Didn't work worth a $hit with asp.net 1.1 and VS 2003. Thanks
Left by GCross on 11/21/2005 2:28 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Your blog saved me from hours of work!!! Thank You!!!
Left by gcctech on 1/20/2006 10:48 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Thanks a lot dude. One of the unsolved mystries solved. I had to resort to Server.Transfer to make it work.
Left by NJM on 3/8/2006 12:23 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Thanks. I thought I'm going crazy... Worked on local computer,but when I uploaded to remote server it wasn't redirecting.
I canceled the Smart Navigator and it solved the problem :)

Anybody knows hot to implement smart navigator and redirection together?
Left by Katya on 3/21/2006 8:32 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar I was able to set SmartNavigation=False on the line right before the Response.Redirect.
Your page will still use SmartNavigation for all other postbacks, up until you click the control that does the redirect.
Left by Doug on 4/20/2006 12:50 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Thanks a lot....One of the myseries has been solved....
Left by Jeetendra on 4/24/2006 12:10 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar We were going crazy trying to find out what went wrong. You guys saved us. Thanks a million.
Left by Amrit Ray on 5/11/2006 5:18 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Same thing was happening to me on the production server. It was working on my development server. The workaround solution is to turn off SmartNavigation right before your Response.Redirect("yourpage.aspx") as noted above:

Page.SmartNavigation=false;
Response.Redirect("yourpage.aspx");

Thanks,
Matt
Left by Lead Internet on 5/31/2006 3:50 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar It will work when you turn on the smartnav . Only you should place the aspnet_client folder to the root of the web site. Cause this folder contains the smartnav js script files and if you turn on the smartnav and if you donot have this aspnet_client folder at your website root the redirections are not working.
Left by Boldpilot on 6/20/2006 8:13 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Thanks , It solved my whole sit of problems , This was a fantastic blog
Left by Nimesh on 9/5/2006 10:54 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar This saved me a ton of time
Left by Thanks on 9/28/2006 9:51 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar After 3 hours of trying to figure out what the hell I was doing wrong, I came across this post.

You guys saved me at least another 3 hours of frustration.
Left by Milton on 11/20/2006 2:55 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Cheers mate, was goin freakin bonkers over this one. After a lot of hours of troubleshotting as to why the flippin server would suddenly change to an internal ip instead of the proper one, I just saw a flash of smartnav something at the bottom of the browser and here I am. MANY thanks from Denmark.
Left by Michael Hansen on 12/7/2006 2:18 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar I had to end up using Server.Transfer. I'm not sure why I was getting the problem, but turning of smart nav didn't do it. Server.Tranfer works like a charm.
Left by Greg on 1/30/2007 4:45 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar I had the exact same problem on one machine (laptop) but not another. I took a look at the aspnet_client folder on both machines and and it turned out that the machine that it was working on had two folders: 2_0_50727 and 1_1_4322 but the laptop only had 2_0_50727. I copied the 1_1_4322 folder over and voilá, everything works fine. 1_1_4322 includes the javascript needed for smartnav to work.

Thank you!!
Left by Bjarki on 2/27/2007 9:42 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar After 2 hours of trying to figure out what the hell I was doing wrong, I came across this post.

Thanks !!
Left by gege on 10/4/2007 8:55 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar
I need the smartNavigation set to true, but just before the Response.Redirect I set SmartNavigation to false, and
it really works!

Thanks a lot for your help!
Left by Manuel on 4/24/2008 10:53 PM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar I have the same problem and none of the above thoughts work. This test site is a virtual site within a SSL site that is working fine. My test is very simple - 2 pages with one button on the login.aspx page. The code from the login.aspx page is below, (in this test no "login" process exist). I never get to page2.aspx. The redirect seems to simply refresh the login page.

Server.Transfer works fine however I want the URL to change.

All works as expected on test servers that are not using SSL.

Any ideas?


protected void Page_Load(object sender, EventArgs e)
{
LinkButton1.Text = "Click here...";

}
protected void LinkButton1_Click(object sender, EventArgs e)
{
try
{
Page.SmartNavigation = false;
Response.Redirect("page2.aspx", false);
}
catch
{
LinkButton1.Text = "Not working";
}
}
Left by whats up on 6/4/2008 10:45 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar I should have mentioned in that last post that the "try" does not fail therefore the "catch" does not execute.
Left by whats up on 6/4/2008 10:49 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Thanks a lot mate.
Left by Murugan on 7/4/2008 7:49 AM
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Gravatar Sounds like it worked great for some, but not for me. The response.redirect falls on its arse, regardless of the SmartNavigation setting. BUT it works fine in IE, just not in Firefox! Grrrr....
Left by owen on 9/18/2008 4:44 AM

Leave Your Comment

Title*
Name*
Email (never displayed)
 (will show your gravatar)
Url
Comment*

 

Preview Your Comment.