Solved

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

Posted on 2011-03-23
2
523 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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

17 Experts available now in Live!

Get 1:1 Help Now