Response.Redirect not redirecting

 Hello all,

 I am trying to use the sample code for testing whether or not a browser accepts cookies ( Unfortunately, I can not get the cookie test page to redirect back to the original page.  I have stripped away everything but the response.redirect statement and tried firing the cookie test page by itself.  The page loads fine, but won't redirect.

 Here is my current code:

 Imports System.Web

Partial Class CookieAcceptanceTest
    Inherits System.Web.UI.Page

    Sub Page_Load()
        Response.Redirect("~/MyIntranet/Pages/Default.aspx", True)
    End Sub

End Class

I am running this from VS2008 with .Net 3.5.  I have not tested on a production server, only on the development server.

If anyone can tell me what I'm doing wrong, I'd greatly appreciate it.





Using Visual Studio 2008 Standard, VB code behind, 2.0, .Net 3.5
9/9/2008 10:22:38 PM 93655 articles. 6 followers. Follow

9 Replies

Similar Articles

[PageSpeed] 10
Get it on Google Play
Get it on Apple App Store


make end response parameter 'false' ;

 Response.Redirect("~/MyIntranet/Pages/Default.aspx", True)

Response.Redirect("~/MyIntranet/Pages/Default.aspx", false) 
or use it like; 

9/10/2008 6:35:23 AM

try using  

if it works fine, then try to re-use
9/10/2008 7:05:55 AM

Thank you both for your repies!  Unfortunately, none of these suggestions worked. In all cases, the initial page loads fine, any other code I place on the page executes fine, but the redirect does not happen.  I don't get any error messages.

Can anyone verify that Response.Redirect will work on the Visual Studio 2008 Pro. built-in development server?

I don't have access to the production server at this time, so I cannot test there; but I've had other problems where features were not supported on the development server.




Using Visual Studio 2008 Standard, VB code behind, 2.0, .Net 3.5
9/10/2008 3:18:25 PM

I can confirm that response.redirect with the second parameter at true (though thats the default so you don't need to provide it, its redundant) works peachy in all versions, as I'm using it extensively from 1.1 to 3.5 in hundreds of scenarios, both in IIS and with the development server (well, not for 1.1).

So yes, it should work. If it doesn't, something beyond what you showed us is causing a problem.

9/10/2008 3:21:01 PM

 Thanks for the confirmation!

The only code I didn't show in my original post is the asp code added to every new web form plus the page title:

 <%@ Page Language="VB" AutoEventWireup="false" CodeFile="CookieAcceptanceTest.aspx.vb" Inherits="CookieAcceptanceTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <title>Cookie Acceptance Test Page</title>
    <form id="form1" runat="server">


I'm assuming that if the problem is that the redirect can't find the target page that I'd get a "file not found" message or something.  Can you confirm this?




Using Visual Studio 2008 Standard, VB code behind, 2.0, .Net 3.5
9/10/2008 3:40:04 PM

 All what response.redirect does (at least, in non-ASP.NET AJAX scenarios, which I see isn't your case anyway) is sent a message to the browser that says "HEY! you should redirect NOW!", and the browser does whatever it wish with it (all major browsers handle it fine). So if the page wouldn't exist, your browser would honor the redirect anyway, and you'd see whatever you see when a page isn't found on any other web site...

So well, I don't see what much could be wrong with the code..did you try it on another machine for kicks?

9/10/2008 3:42:15 PM

 I got it working.  The problem was the lack of a "Handles Me.Load" clause in the Page_load subroutine declaration.  Which, if you include the "Imports System.Web" statement, makes two critical pieces of code that were left out of the Microsoft example.


Thank you all for your help!!!


Using Visual Studio 2008 Standard, VB code behind, 2.0, .Net 3.5
9/10/2008 4:09:48 PM
the handles statement isn't required if you use automatic event wireup, which was probably the case. Import statements are almost always missing from examples... you eventually get used to it =P
9/10/2008 4:11:32 PM

 Yeah, I've run into that missing "Imports" statement before.  I just sent Microsoft some feedback on the example I was using to point out that us newbies lose a lot of time over omissions like that.

Thanks for the comment about the AutoEventWireup.  I've never really paid attention to that and will obviously need to learn more about it.


Thanks again, if it weren't for helpful souls like you, I'd be significantly more ignorant than I am now.


Using Visual Studio 2008 Standard, VB code behind, 2.0, .Net 3.5
9/10/2008 4:35:18 PM

Similar Artilces:

web form
I have a web form with some text boxes with validation to ensure that data has been entered. I have two buttons one for "submit" and one for "Return to main". When I click on submit - all works OK as it should with asking the user to enter data for the text boxes. However, when I click "Return to main", instead of redirecting to the main page, the validation requirements for the form appear. Here is some of my code... <table> <tr> <td valign="top" style="width: 318px"><asp:TextBox id="txtTextBox1" runat=&quo...

Forms Authentication
Hi I am creating a new Website Application that redirects the logged in user to a webpage based upon the role to which he belongs programatically in 'Authentication' event. I have designed the app. so that a User can belong to a single role at one time and I am using membership provider.  I have a web page that is stored in the rootfolder which is accessible by all users(including unauthenticated users). This webpage contains different menuitems and one of them is 'login'.  So If user A belongs to Role 'abc', he is redirected to a webpage in folder abc. S...

I wrote code Response.Redirect then page is not redirected to reqquested page (
I wrote code Response.Redirect then page is not redirected to reqquested page  (with make sure that your target URL is valied and correct... or the problem might be from your browserRegards...Nassar, RamiMy Blog || E-Mail Don't forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped. dear, just paste the code so that we can assist u accordinglyKind Regards,Saurabh Sharmaonly dead fish swim along the flow of river, learn to make yo...

Redirect after login
Hi, I would like different url's navigated to after users log in, according to their rolegroup. It was suggested that I use Response.Redirect coding, but so far I have had no success in getting it to work! Could somebody take a look at it for me and suggest why it wouldn't work? Here it is:     protected void Login1_LoggedIn1(object sender, EventArgs e)    {        if (Page.User.IsInRole("Buyers"))        {          ...

Should we use Response.Redirect ( url, true) or Response.Redirect ( url, false) ?
Normally most of the time we use Response.Redirect (url). How is this different from Response.Redirect ( url, true) or Response.Redirect ( url, false) ? Also, what is the best form of Redirect to use when going to another page?sun21170 The second parameter of Response.Redirect is endResponse which is boolean value that indicates whether to stop running the current page.It depends on if you want to keep it alive or stop it.Thanks Mark post(s) as "Answer" that helped youElectronic ScrewWebsite||Blog|| In what situation, would someone pass a true for the endResponse ...

Too many redirects caused by response.redirect
I added a sitemap to Google a couple of days ago and now I see that there are 'warnings' on several pages 'because they contained too many redirects'. These re-directs are response.redirects to other pages when I continue processing the user requests -- as part of the normal web-site functionality.  For example, if they press the button OK, then do something and send them to page 'x' and I do that using response.redirect. Now, Google does not seem to like response.redirect and it has been temporarily pointed to the destination page -- which is not good!  I...

Response.Redirect not redirecting from custom handler
Hi, I have written a custom client-side handler to handle the onkeypress event which I added to an asp:TextBox using the attributes collection. During the event I pass the ClientID of a submit button and if the keypress is the return key then I explicitly call the click() event of the button. This is working to the extent that I can set a breakpoint on the asp server-side event handler for the button click which is reached. The problem is that it seems to be executing the Response.Redirect("blah.aspx") but doesn't actually redirect. This code is working ok if you submit the for...

web form redirect
I have a webform (test1.aspx).  On that I have a formview connected to a sql database.  I have it defaulted to show the insert item template.  I have it working and the data is getting inserted, but after the insert I want it to redirect to a different page (menu.shtml).  What do I need to do to get this acomplished? Thanks in advance. If you're using a SqlDataSource, just hand the OnInserted event and call Response.Redirect(...). Do you have a button or link that commits the record?  If so, put this in the last line:  Response.Redirect("menu...

Redirect a web form
Hi, how can I redirect a web form to another web form that is in another project but in the same solution???? Thanks a lot Cico Context.Response.Redirect("/ProjectName/pagename.aspx") Hey! It compiles! Ship it! Cheers, Venugopal Mallarapu. Visit : My Blog Thanks, but now I have a new problem... impossible loading the type 'webGCA.Global' (webgca is my project name) <%@ Application Codebehind="Global.asax.vb" Inherits="webGCA.Global" %> What kind of mistake I have made this time??? Thanks Cico...

Should it be Response.Redirect("~/NextPage.aspx") or Response.Redirect("NextPage.aspx") ?
Hi all,For all references to pages and images that are in the same directory as the current ASPX page, is it necessary to use the "~/" prefix to the pages? Both seem to work, although at times when I upload my code to a shared hosting environment, having the "~/" causes the page to error out.Which one is correct and loads faster?Thanks.  There is a difference between the two. the "~/" means starting from the Application root. Let's say you have this file structure. approot/page1.aspx approot/subfolder/page1.aspx approot/subfolder/page2.aspx If I do Response.Redirect("page1.aspx") ...

Response.Redirects sometimes redirect to wrong page
Strange error. I have some buttons wired to do a response.redirect, but (rareley) they sometimes redirect to the wrong page. I have never seen this before. The app does not break, but I need to try to troubleshoot it. Any help appreciated.--[_]-[_]--AGENT_SMITH a bit of code would help along with an example of where you might be re-directed besides the correct page? Nothing earth-shattering... private void btnHome_Click(object sender, System.EventArgs e) { Response.Redirect("../"); } Redirects to ../reports/report.aspx --[_]-[_]--AGENT_SMITH I'm s...

Response.redirect always redirects to default.aspx
In my code i have added a few back buttons or button on which after clickingthe users must be returned to where he came from. rather than using a javascript with the window.back.... function i use response.redirect because of database accesses inbetween etc etc. Now i formed my response.redirect the following way: Dim sUrl As String sUrl = FormsAuthentication.GetRedirectUrl(oMember.nickname, True) Response.Redirect(sUrl) So as you see i try retrieving the redirect url via formsauthenticaton but it always redirects to default.aspx, why is that and how ca...

No response from response.redirect
Hi, my project has atleast 10 webforms and for navigation the response.redirect was working fine till today. It stopped working in one of the pages but stills fine in the other pages. eg. the CANCEL button loads the previously navigated page. All CANCEL except one are working. I checked the button click event, put labels with messages in them; the labels get posted when the button is clicked; but when i remove the labels and put in the response.redirect("PAGE NAME") it stopped working; i even put the wrong path in the response.redirect, still the errorhandler or any o...

Whic one correct? Between Response.Redirect(@"~\Default.aspx") and Response.Redirect(@"~/Default.aspx")
It seems the both  Response.Redirect(@"~\Default.aspx") and Response.Redirect(@"~/Default.aspx") can work well, but could you tell me which one is correct? Thanks! SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip filesSuperCool Random Number Generator  common practice is to write it like Response.Redirect(@"~/Default.aspx") Thanx, [KaushaL] || BloG || Profile || Microsoft MVP"I would love to change the world, but they won’t give me the source code"Don't forget to click "Mark as Answer" on...

Web resources about - Response.Redirect not redirecting -

Advertise - Redirecting - YouTube
Search Call us: 1-855-500-2756 Get started Overview Why it Works Success Stories Get Started Make Video Ads Resources This page has moved. Redirecting ...

Aboriginal funds need redirecting - report
Aboriginal funds need redirecting - report

Freedom of speech: Redirecting our society to a dangerous course
Freedom of speech: Redirecting our society to a dangerous course

Leaked Federal Government mental health report recommends redirecting $1 billion from acute hospital ...
A report commissioned by the Federal Government recommends redirecting money from acute hospital care to community-based mental health services. ...

Sona talked of redirecting voters to wrong polls, court hears in robocalls trial
Michael Sona was overheard talking about American-style campaign politics to redirect voters to the wrong polling stations in the 2011 federal ...

Unscrupulous website adverts again redirecting some users to App Store from Safari
... granting any kind of permission… In iOS 8 beta 2, Apple supposedly had remedied the issue: “Safari now blocks ads from automatically redirecting ...

Play Store May Be Redirecting Some Search Terms To The Predefined Categories
The user experience on Android is never standing still, which is no more evident than in the Play Store itself. It seems Google may be trying ...

Please wait — redirecting to new Business page...

Click here if you are not redirected

Redirecting Financial Flow To Asia Pacific Crucial For Region’s Sustainable Growth
... (UNEP) notes, the Asia Pacific region is home to over half of the world’s population, but much less than half its natural resources. Redirecting ...

Resources last updated: 2/5/2016 6:07:39 AM