Solved

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

Posted on 2011-03-23
2
528 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

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 …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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