Web.config授权问题 [英] Web.config authorization issue

查看:79
本文介绍了Web.config授权问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

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



我使用Visual Studio 2012和MVC4。



我尝试过:



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



Hello,
I'm experimenting some issues with my web.config authorization configuration. I just want to allow any user to access on the "lost password" and "create account" pages, all other pages need to be authenticated.

I am using Visual Studio 2012 and MVC4.

What I have tried:

Here is what I have in my main web.config file.

<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>





我'我的登录表单中有一些链接可以在这2页上找到,这些链接在没有这个配置的情况下工作正常,但总是将我重定向到登录页面。



可以有人在这一点帮助我吗?



提前致谢并对不起我的英语。



I've got some links in my login form to go on this 2 pages, these links works fine without this configuration but always redirect me to the login page with it.

Could someone help me on this point?

Thanks in advance and sorry for my english.

推荐答案

删除路径中的 .cshtml 扩展名。您需要指定控制器操作的路径,而不是视图的路径。
Remove the .cshtml extension from the paths. You need to specify the path of the controller action, not the path of the view.


这篇关于Web.config授权问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆