ASP.NET MVC的会员资格:谁应该提供与QUOT; RETURNURL"登录方法? [英] ASP.NET MVC Membership: Who should provide "returnUrl" to the LogOn method?

查看:99
本文介绍了ASP.NET MVC的会员资格:谁应该提供与QUOT; RETURNURL"登录方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是登录后的操作方法的定义

Here's the definition of the LogOn post action method

[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
  // more inside
}

我有一个基本的问题。该框架是否提供了字符串RETURNURL ?或者我有责任吗?

感谢您的帮助。

推荐答案

这要看是谁调用此方法是否该参数在POST请求提供。例如,如果用户试图访问装饰用 [Autorize] 属性的控制器动作,他未通过身份验证的框架会自动重定向到 LogOn支持行动(即呈现形式,而不是一个与一个 [HttpPost] ),并提供 RETURNURL 参数。然后,你可以有一个隐藏字段中的登录表单坚持它的价值,这样,当用户输入他的凭据并提交表单的 LogOn支持行动,成功登录的情况下, ,他将被重定向到最初请求的页面。

It depends on who is calling this method and whether this parameter is supplied in the POST request. For example if the user tries to access a controller action decorated with the [Autorize] attribute and he is not authenticated the framework will automatically redirect to the LogOn action (the one that renders the form, not the one with [HttpPost]) and supply the returnUrl parameter. Then you could have a hidden field in the logon form to persist its value so that when the user enters his credentials and submits the form to the LogOn action, in case of successful login, he is redirected to the initially requested page.

这篇关于ASP.NET MVC的会员资格:谁应该提供与QUOT; RETURNURL"登录方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆