How to set the ReturnUrl for the Login link in MVC 3 app?

Posted by user762196 on Stack Overflow See other posts from Stack Overflow or by user762196
Published on 2011-06-22T23:45:14Z Indexed on 2011/06/23 0:22 UTC
Read the original article Hit count: 166

using System;
using Microsoft.Practices.Unity;

namespace <MyNameSpace>
{
    public class UrlFactory
    {
        public static UrlFactory Current
        {
            get { return HttpApplicationUnityContext.Current.Resolve<UrlFactory>(); }
        }

        public string GetLoginUrl()
        {
            return String.Format("{0}/login?ReturnUrl={1}", MyConfig.BaseHttpUrl, <GET_PAGE_URL>);
        }
}

The user can be on any page on the site and click the Login link. But the ReturnUrl must always point to the exact page where he clicked it. I must take the user back to the page he clicked the login link.

In my code above, how do I get the page url in

<GET_PAGE_URL>?

Thanks

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc-3