3

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.

0

2 Answers 2

2

FormsAuthentication.RedirectToLoginPage("extra query string");

MSDN

Sign up to request clarification or add additional context in comments.

2 Comments

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.
so, added it to the initial URL then
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.