2

如果用户未通过身份验证,我将以下内容添加到我的 web.config 以将用户重定向到登录页面,但是转到 URL 会导致重定向吗?

 <location path="user/add">
    <system.web>
      <authorization>
        <deny users="?" />
      </authorization>
    </system.web>
  </location>

我有设置表单验证。像这样:

<authentication mode="Forms">
      <forms loginUrl="/user/login"
             protection="All"
             timeout="30"
             name="MyCookie"
             requireSSL="false"
             slidingExpiration="true"
             defaultUrl="default.aspx"
             />


    </authentication>

使用 .net 和 mvc。

4

3 回答 3

2

你有那个动作或控制器的“授权”属性吗?

于 2008-11-28T03:37:45.573 回答
0

也许您也应该尝试允许用户标签来检查这部分是否有效?

嗯,我猜评论中不允许使用尖括号?所以我把它们改成小括号。

(位置路径=“用户/添加”)

(system.web)
  (authorization)
    (allow users="testuser" /)
    (deny users="*" /)
  (/authorization)
(/system.web)

(/地点)

于 2008-11-28T07:36:42.750 回答
0

对于我的一个应用程序,我在与以下相同的节点中有以下内容<authentication>

<authorization>
    <deny users="?"/>
</authorization>

但这涵盖了整个应用程序......

于 2008-11-28T01:25:29.753 回答