views:

97

answers:

2

I put the authentication attribute that sets:

filterContext.Result = new HttpUnauthorizedResult();

so when I try to access

http://www.mysite.com/Forum/Polls

and I am not authenticated I am redirected to:

http://www.mysite.com/Account/Log?ReturnUrl=%2FForum%2FPolls

I want to have the following line instead:

http://www.mysite.com/Account/Log?back=%2FForum%2FPolls

, so instead of 'ReturnUrl' need 'back'. Where I can ovveride this behaviour. Thanks.

A: 

It doesn't look like you can. That comes from System.Web.Security.FormsAuthentication.GetLoginPage() If you look at the code, you see that it is indeed a hard coded literal. At least in System.Web version 2.0.0.0

Matthew
+1  A: 

You can rewrite "ReturnURL" on EndRequest event.

This is sample code.

protected void Application_EndRequest()
{
  if (Response.StatusCode != 301 && Response.StatusCode != 302) return;

  var targetUrl = Response.RedirectLocation.Replace("ReturnUrl","back");
  Response.RedirectLocation = targetUrl;
}

Hope this code.

takepara