I want to remove \"returnurl=/blabla\" from address bar when a user want to access to a login required page. Because I\'m trying to redirect the user to a static page after
Create a custom Authorize Attribute
public class CustomAuthorizeAttribute : AuthorizeAttribute
{
public override void OnAuthorization(
AuthorizationContext filterContext)
{
if (filterContext == null)
{
throw new ArgumentNullException("filterContext");
}
if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
{
string loginUrl = "/"; // Default Login Url
filterContext.Result = new RedirectResult(loginUrl);
}
}
}
then use it on your controller
[CustomAuthorizeAttribute]
public ActionResult Login()
{
return View();
}