MVC 5 - 授权蓝显与表单身份验证

时间:2015-06-08 18:59:21

标签: asp.net-mvc forms-authentication

使用WebForms我没有表单身份验证的问题,但它让我对MVC 5感到悲伤

向区域添加Secure,然后登陆和登录

MVC areas

在主web.config文件中添加了这个在system.web下(也是~/Secure/Login之类的变体)

 <authentication mode="Forms">
  <forms loginUrl="Secure/Login" />
</authentication> 

并且子web.config文件(在安全下)这个(抱歉缩进不起作用所以使用的代码片段)

<location path="">
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>
  <location path="Login">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>
  </location>​

但由于某种原因,它不起作用。

1 个答案:

答案 0 :(得分:0)

将此添加到Startup.Auth并且它完美运行

app.UseCookieAuthentication(New CookieAuthenticationOptions() With {.LoginPath = New PathString("/Secure/Login")})
相关问题