asp.net c# 中的安全页面
我的配置:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode ="Forms">
<forms name ="loginpage" loginUrl="login_to_secure3700.aspx" />
</authentication>
</system.web>
<location path ="securedpages/bob.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
这样,只有正确输入用户名和密码后,才能访问 pag bob.aspx。 但是,这仅适用于页面 bob.aspx,我怎样才能使其适用于例如 50 个页面,但所有页面都具有不同的登录名和密码。 ?
config I have :
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode ="Forms">
<forms name ="loginpage" loginUrl="login_to_secure3700.aspx" />
</authentication>
</system.web>
<location path ="securedpages/bob.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
This way the pag bob.aspx will only be accessible when the username and password were entered ok.
BUT , this works only for page bob.aspx, how can I make this work for eg 50 pages, but all with different logins and passwords. ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有两个选项:
通过拒绝所有用户来保护每个页面,并仅允许 bob 访问 bob.aspx 和 helen 访问 helen.aspx。鉴于上面的答案,您肯定会管理这一点,但这很麻烦:对于每个新用户,您都需要更改配置。
我认为更好的方法是创建一个!页面 (user.aspx) 并获取已登录的用户并为此用户个性化该单个页面。这更容易维护,并且您可以将所有代码放在一页上。
如果您想在页面名称 (bob.aspx) 中保留个性化方法,您可以查看 URL 重写。
There are two options:
Secure each page with deny all users and only allow bob on bob.aspx and helen to helen.aspx. Given the answers above you will manage that fore sure but it is cumbersume: for every new user you need to change your config.
I think the better way is to create one! page (user.aspx) and take the user that is logged in and personalize that single page for this user. This is a lot easier to maintain and you will have all the code on one page.
If you want to keep the personalized approach in the pagename (bob.aspx) you can have a look into URL rewriting.
您可以添加多个路径,如下所示:
或更简单,只需添加受保护页面的目录:
You could add multiple paths like this:
Or more simple, just add the dir of the secured pages:
您可以将所有 50 个页面放在一个文件夹中,并在该文件夹中为它们添加 1 个 web.config,其中包含
即使它们具有不同的登录名和密码也没关系。
you can put all the 50 pages in one folder and the add 1 web.config for them in this folder that contains
It does not matter if they have different logins and password.