开发者

How to read the ReturnUrl query parameter from Loginpage in my MVC 3 controller?

开发者 https://www.devze.com 2023-03-14 15:55 出处:网络
I have this url in my login page: http://localhost:5550/login?ReturnUrl=/forum/456 I have this controller:

I have this url in my login page: http://localhost:5550/login?ReturnUrl=/forum/456

I have this controller: [HttpPost] public ActionResult Try(LoginModel model){ //How can I read the ReturnURL query string parameter and other params inside my controller?

//what is the recommended way to do this? }

Tha开发者_如何学编程nks


Have you tried HttpContext.Request.UrlReferrer.AbsoluteUri?

That should give your your host's URL.

EDIT: Seems you changed your post's question!

I'm not sure this is what you want but to get the ReturnUrl part in your controller, you can pass the string ReturnUrl to your controller for example:

[HttpPost]
public ActionResult Try(LoginModel model, string ReturnUrl)
{
    // bla bla bla
}

You'll get the "/forum/456" as a string.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号