I would like to pass a querystring value from the url to the default login url page in forms authentication. Any ideas of how this can be achieved. Searched around and did not find anything useful. Thanks.
2 Answers
FormsAuthentication.RedirectToLoginPage("extra query string");
2 Comments
Lucky Luke2
Hi, im clicking a link from an email with url and query string parameter, initially i wont be logged in so asp.net will redirect me to loginurl page defined in the web.config. It is here that i need to pass the value. I dont see where i could use this answer.
Ted
so, added it to the initial URL then
This worked for me:
web.config:
<authentication mode="Forms">
<forms loginUrl="~/Account/MyLogOn" timeout="30"... />
</authentication>
controller:
[AllowAnonymous]
public ActionResult MyLogOn(string aValue)
{
//aValue contains my querystring: 12345
return RedirectToAction("Action", "Controller", new {AValue = aValue});
}
URL:
http://mysite/?aValue=12345