0

我敢肯定这个问题的变体以前已经被问过很多次了,但我找不到答案。

我有一个网站,它是一个在线商店。我们有以下登录/帐户管理要求:

Admin 角色的成员登录 /Admin Pro 角色的成员登录 /Pro Customer 角色的成员没有他们登录的特定区域,但在结帐时我们希望他们能够登录,这样他们就不会登录不必再次填写他们的交货详细信息。

因此,我们希望 url 结构类似于:

/Checkout.aspx (/login form) /Admin/Login.aspx /Pro/Login.aspx (这里唯一的小例外是我们确实希望用户能够访问 /Pro/Register.aspx 页面而无需登录在 - 出于显而易见的原因)

我读到如果我从主 web.config 中删除身份验证配置并在每个 pro 和 admin 文件夹中创建一个 web.config 文件,这是可能的。在 IIS 7 中,我将文件夹更改为应用程序,但页面无法从主站点访问母版页。

我是否以正确的方式进行?

提前致谢。

4

2 回答 2

0

我不知道您为什么需要将文件夹更改为应用程序,但您在每个子目录中创建“子”web.config 文件的策略是实现此目的的一种正确方法。

另一种方法是在根 web.config 中为每个页面或目录声明权限,如下例所示(来自此处):

<configuration>
    <system.web>
        <authentication mode="Forms" >
            <forms loginUrl="login.aspx" name=".ASPNETAUTH" protection="None" path="/" timeout="20" >
            </forms>
        </authentication>
<!-- This section denies access to all files in this application except for those that you have not explicitly specified by using another setting. -->
        <authorization>
            <deny users="?" /> 
        </authorization>
    </system.web>
<!-- This section gives the unauthenticated user access to the Default1.aspx page only. It is located in the same folder as this configuration file. -->
        <location path="default1.aspx">
        <system.web>
        <authorization>
            <allow users ="*" />
        </authorization>
        </system.web>
        </location>
<!-- This section gives the unauthenticated user access to all of the files that are stored in the Subdir1 folder.  -->
        <location path="subdir1">
        <system.web>
        <authorization>
            <allow users ="*" />
        </authorization>
        </system.web>
        </location>
</configuration>
于 2011-06-22T15:46:27.967 回答
0

你不应该创建一个新的应用程序;只需为您的子文件夹包含一个 web.config,授权仅允许您希望能够访问该文件夹的角色。

于 2011-06-22T15:47:48.097 回答