简体   繁体   English

为什么未通过身份验证的用户不能通过Membership API自动重定向到“登录”页面?

[英]Why isn't the un-authenticated user automatically redirected to the Login page with Membership API?

Building a sample ASP.NET MVC app. 生成示例ASP.NET MVC应用。 Using the Membership API for authentication. 使用会员资格API进行身份验证。 For whatever reason, the code execution first goes to the default route (eg HomeController.Index method) instead of going to the specified login page. 无论出于何种原因,代码执行都会首先转到默认路由(例如HomeController.Index方法),而不是转到指定的登录页面。

My web.config is as follows: 我的web.config如下:

<authentication mode="Forms">
  <forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>

What am I missing? 我想念什么?

您需要在ActionController上放置[Authorize]属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM