Web.config授权问题

时间:2018-10-22 16:54:56

标签: c# asp.net-mvc web-config authorization

我正在使用web.config授权配置尝试一些问题。 我只想允许任何用户访问“丢失的密码”和“创建帐户”页面,所有其他页面都需要进行身份验证。

我正在使用Visual Studio 2012和MVC4。

这是我的主要web.config文件中的内容。

<system.web>
    <authentication mode="Forms">
        <forms loginUrl="~/Account/Login" defaultUrl="~/Account/Login" timeout="120" />
    </authentication>
    <authorization> 
        <deny users="?"/>
    </authorization>
</system.web>

<location path="~/Account/Create.cshtml">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
</location>

<location path="~/Account/LostPassword.cshtml">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location> 

我在登录表单中有一些链接可以进入这两个页面,这些链接在没有此配置的情况下仍然可以正常运行,但始终使用它将我重定向到登录页面。

有人可以帮我吗?

在此先感谢您的英语。

0 个答案:

没有答案
相关问题