MVC授权每次都要求登录

时间:2016-04-13 06:23:27

标签: asp.net-mvc authentication web-config forms-authentication

我在控制器上使用autorize属性

  [Authorize(Roles = "Investor")]
public class InvestorIncomeController : Controller
{
  // some stuff 

当我注册新帐户并尝试使用此控制器时,它每次都要求再次登录并再次登录后才能运行。

在webconfig文件中

<system.web>
<authentication mode="Forms" />
<compilation debug="true" targetFramework="4.5" />


<httpRuntime targetFramework="4.5" />

我想如果用户一次登录他不应该一次又一次登录。

1 个答案:

答案 0 :(得分:0)

您应该将此属性放在Register方法之上。

[AllowAnonymous]
public ActionResult Register()
{

}