.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

ASP: How to redirect a requst to another page?

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :WPF


In the onload function of an asp site I have to decide if the request has to handle in this page or has to redirect to another page.

Now I'm looking how to realize this redirect functionality in the onload methode of my asp site.

Thanks Tony

View Complete Post

More Related Resource Links

Redirect to a mobile page

Hi please can anyone help? I have a simple website with a home page called defaut.aspx, also I have a page with in this site called mobile.aspx. My question is, bearing in mind that I posses very little knowledge of VB, what code do I need to place in the default.aspx to detect what kind of device someone is using and redirect them to the mobile page (mobile.aspx)? This needs to be quite up-to-date preferably for blackberry and nokia devices?


Detecting PPC device on startup page to redirect?

I was wondering (since a search didn't find any posts) if there is a way for my startup page to detect what kind of device (PocketPC or web browser specifically) is loading the page and if it is a PocketPC, then redirect to the mobile pages? I will only be using PocketPC's exclusively as a mobile device.

Thanks for any suggestions!

After login redirect to a desired page

Hi,   Just a simple question. After I click login button, I want to page be redirected to display.aspx. How to set up it? Sorry for the silly question.

How to set the variation root redirect page to ALWAYS go to a preset label?

Hi. I have setup variations and I have 4 labels, SE EN FI DK. This is a public website and I want every visitor to first be directed to the predetermined label, for example SE. This no matter what setting they have in their browser... In Sweden, most people have English as the language in the browser since this gets you better content in most places, but in this case, it gets them the EN label instead of the SE label as default. How can I change this in the best way possible? Are there any easily adaptable solutions available? Like on codeplex? The MSDN way is not to my liking, manually customize every front end or compile my own DLL....Noo, there has to be a better way right? (How to: Customize the Variations Label Control Logic http://msdn.microsoft.com/en-us/library/ms551625.aspx) Appreciate any help you can give me on this. RegardsThomas BalkestÃ¥hl - Technical Specialist - SharePoint

Response.Redirect in C# for page to page parameter passing

Looking for examples of this, but can't find anything specific. I'm new to ASP.NET, and C# at the same time... so I'm struggling to get it right...  Thanks, Nick

Authentication required, redirect to login page

Hi,I want authentication required for all webpages in a site. If i copy the url of any of the web page in the current site and paste it in the url address i should redirect to login page. If you have any solution please suggest it.

SPWeb.Properties is not persist over the redirect page.

Hi, I have to pass some object from my code to another redirected page. So I serialize the object and serialized string is save to SPWeb's property as a string and after that I use SPUtility.Redirect('Url'). But on redirected page above updated property is not find in the SPWeb.Property collection. string xml = MyClass.GetXMLFromObject(exInfo); SPContext.Current.Web.Site.RootWeb.AllowUnsafeUpdates = true; SPContext.Current.Web.Site.RootWeb.Update(); if (!SPContext.Current.Web.Site.RootWeb.Properties.ContainsKey("MyInfo")) { SPContext.Current.Web.Site.RootWeb.Properties.Add("MyInfo", xml); SPContext.Current.Web.Site.RootWeb.Update(); } else { SPContext.Current.Web.Site.RootWeb.Properties["MyInfo"] = xml; SPContext.Current.Web.Site.RootWeb.Update(); } SPContext.Current.Web.Site.RootWeb.AllowUnsafeUpdates = false; SPContext.Current.Web.Site.RootWeb.Update(); SPUtility.Redirect("RedirectToErrorPage/ApplicationPage1.aspx?ExInfo=" +xml, SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); Redirected page code: if (SPContext.Current.Web.Site.RootWeb.Properties["MyInfo"] != null) { using (SPWeb web = SPContext.Current.Site.OpenWeb(SPContext.Current.Web.Site.RootWeb.Url)) { TextBox1.Text = Convert.ToString(SPContext.Current.Web.Site.Root

how to redirect user to login page if session is null

i have 2 page,1.login.aspx ---  2.welcome.aspxin my login.aspx im storing username into sesssion as below:Session["usernm"] = txtUsername.Text;in my welcome.aspx  pagein page_load event if (Session["usernm"]==null)        {            Response.Redirect("Login.aspx");        }----- here if i manulally paste the url ( http://localhost:4125/Loginado/welcome.aspx) it should go to  login.aspx for user credentialsbut its going directly to welcome.aspx  page.

Redirect to Login Page from Generic Handler

Hi,I have created a asp.net generic handler to use it in auto-complete text box. Here is my code to it /// <summary>     /// Summary description for $codebehindclassname$     /// </summary>     [WebService(Namespace = "http://tempuri.org/")]     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]     public class ProductSearch : IHttpHandler, IReadOnlySessionState     {         public void ProcessRequest(HttpContext context)         {             String query = context.Request.QueryString["q"];             if (! string.IsNullOrEmpty(query))             {                 int sid =  Convert.ToInt32(HttpContext.Current.Session["ScenarioID"]);                 int evId =  Convert.ToInt32(HttpContext.Current.Session["EventID"]);                 var products = from p in Data.BO.Product.GetScenarioProducts(sid, evId, query) select new { id = p.ID, name = p.Name };                &nbs

Redirect to specific page based on user Roles

I am using Formsauthentication. My situation is as per below:the login form has codebehind :==============================protected void LoginButton_Click(object sender, EventArgs e)        {            TextBox uname = Login1.FindControl("UserName") as TextBox;            TextBox pass = Login1.FindControl("Password") as TextBox;            CheckBox rm = Login1.FindControl("RememberMe") as CheckBox;            Literal fail = Login1.FindControl("Literal1") as Literal;            if (Membership.ValidateUser(uname.Text, pass.Text))            {                /                FormsAuthentication.SetAuthCookie(uname.Text, rm.Checked);                            }        &

How to catch error in session variable in globals.asax(Application_Error) and redirect to same page

Hi, i have a login page where username got to enter his/her username or password. When you try to enter any scripting over there eg:'<asd>' it gives an error  'Server Error in '/' Application' 'A Potentially dangerous Request. Form value was detected from client' I don't want to redirect user to custom error page when such unpredictable error occurs. infact i got a label on the same page itself where error's are displayed. how can i display such errors on this very same label. can i do that using globals Application_Error ?. Session variable not working here. Please give me the exact steps for how i can catch and display the error which are not validated. waiting for reply thanks and regards, Learning Programmer

Session time out alert box and redirect login page


Dear all,

Now I am using Form authentication for my website. 

It is something like that below. But if I left the website without using it for quite some time and when I used it back, it is redirected to the login page. 

The one I want to know is that it is because of session expire or cookies expire. And if it is session expired, I want to show the alert box and redirect to the login page. And one more thing is that if the user keeps on using the website, I want to extend the session expire time. If you do not mind, I want to have some references for this scenario. Thank you so much.


If myUser.IsValidUser(txtUserName.Text.Trim, txtPassword.Text.Trim) = True Then

SharePoint Couldn't redirect to another page after document check in


Hi all,

I want to redirect to other page after check in the document in the document library. So I coded in ItemCheckedIn event.

But the problem was raised:

  • When I click the Check In button, system would pop up the message "The file could not be checked in. It may already been checked in by another user." (But it would check in the document later).
  • It couldn't redirect to other page after checking in.

Can anyone help?Thx.


Can't redirect to other page after document checked in


Hi all,

I want to redirect to other page after check in the document in the document library. So I coded in ItemCheckedIn event.

But the problem was raised:

  • When I click the Check In button, system would pop up the message "The file could not be checked in. It may already been checked in by another user." (But it would check in the document later).
  • It couldn't redirect to other page after checking in.

Can anyone help?Thx.

How to make a MVC controller redirect to a web form page?


I am asked to build a MVC page on top of a existing web form site. I need to let the controller return a web form page instead of a view page. Is there any way I could achieve this?

redirect only one user for that page



I have asp.net membership login in my asp.net application in that i have 30 users, What i need is

I have one xxxx.aspx page if user name 'John' is logged in then i need to redirect to that page xxxx.aspx and other user will not able logged in to that page except 'john'.. so let me know how to do this

After Login , Redirect To Previous Page Instead Of Destination URL set


Hi .

I have developed an asp.net project with asp.net membership for login.

I have login control in a page and for that I have set the property destination URL to a particular page say defaultlogin.aspx.

It is also working fine, when I use to login from home page.

But if i navigate to different pages of my website say first to home page, contact us page, about us page etc. Then after that when I click on login page and key up the login information in the login control.

I use to redirect to the last page which I have visited the last. It is not redirecting to the destination page which I have set in the login control.

What's the problem here?

Plz help me with the above issue.

Thanx in advance.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend