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.
posted on Thursday, September 15, 2005 6:19 AM | Filed Under [ Tips Tricks and Frustrating Errors ]

Comments

Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Mischa Rihm
on 9/24/2005 2:47 PM
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?
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by JT
on 9/30/2005 2:53 PM
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.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Manikandan.N
on 10/17/2005 9:12 AM
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
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by JoDaCoda
on 11/2/2005 12:45 PM
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.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Skittles
on 11/5/2005 1:04 PM
Thank you, thank you, thank you. I have a presenation to do and I couldn't get past this. Thanks again.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by GCross
on 11/21/2005 2:28 PM
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
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by gcctech
on 1/20/2006 10:48 AM
Your blog saved me from hours of work!!! Thank You!!!
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by NJM
on 3/8/2006 12:23 PM
Thanks a lot dude. One of the unsolved mystries solved. I had to resort to Server.Transfer to make it work.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Katya
on 3/21/2006 8:32 AM
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?
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Doug
on 4/20/2006 12:50 PM
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.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Jeetendra
on 4/24/2006 12:10 PM
Thanks a lot....One of the myseries has been solved....
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Amrit Ray
on 5/11/2006 5:18 AM
We were going crazy trying to find out what went wrong. You guys saved us. Thanks a million.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Lead Internet
on 5/31/2006 3:50 PM
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
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Boldpilot
on 6/20/2006 8:13 AM
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.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Nimesh
on 9/5/2006 10:54 AM
Thanks , It solved my whole sit of problems , This was a fantastic blog
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Thanks
on 9/28/2006 9:51 AM
This saved me a ton of time
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Milton
on 11/20/2006 2:55 PM
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.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Michael Hansen
on 12/7/2006 2:18 PM
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.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Greg
on 1/30/2007 4:45 PM
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.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Bjarki
on 2/27/2007 9:42 AM
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!!
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by gege
on 10/4/2007 8:55 AM
After 2 hours of trying to figure out what the hell I was doing wrong, I came across this post.

Thanks !!
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Manuel
on 4/24/2008 10:53 PM

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!
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by whats up
on 6/4/2008 10:45 AM
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";
}
}
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by whats up
on 6/4/2008 10:49 AM
I should have mentioned in that last post that the "try" does not fail therefore the "catch" does not execute.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by Murugan
on 7/4/2008 7:49 AM
Thanks a lot mate.
Gravatar
# re: Response.Redirect not working (I'm looking at you SmartNavigation)
Posted by owen
on 9/18/2008 4:44 AM
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....
Post Comment
Title *
Name *
Email
Url
Comment *  
Please add 7 and 5 and type the answer here: