Solved

ASP.NET Membership - stop redirection to last page on login.

Posted on 2011-03-23
2
525 Views
Last Modified: 2012-05-11
When using ASP.NET Membership if a user lets his system go idle and the login expires then the next request will force the user to the Login page.  The Url then contains a redirect parameter like this...

http://localhost/CARS/Login.aspx?ReturnUrl=%2fCARS%2fAgreements.aspx

Then when the user logs in again it takes them to the last page they were on.

I can see how this could potentially be a handy feature.  But is there any way to turn it off?
0
Comment
Question by:JosephEricDavis
2 Comments
 
LVL 7

Accepted Solution

by:
nbove earned 500 total points
ID: 35202884
You cannot override the ReturnURL behavior.  It is integrated into the membership mode.  However, you can work around the behavior.

In your login.aspx page, you can inspect the value of ReturnUrl in the Request.  If it contains a value, then simply redirect to the login page without the return url string.

Here is a code snippet:
      if (!string.IsNullOrEmpty(Request["ReturnUrl"])) {
        Response.Redirect("Login.aspx");
      }

Open in new window

0
 
LVL 7

Author Comment

by:JosephEricDavis
ID: 35202898
Yes, I've already thought about this as a solution.  I'm just surprised that there isn't a built in way to override as it seems like a common enough configuration need.

If anyone else has any input on this I'm going to keep this question open for a while.  Otherwise I'll just award you full points.

Thanks.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now