简体   繁体   English

如何拒绝ASP.net中的链接?

[英]How to deny link in ASP.net?

I have problem as follow , i will checked "group" and not access some link in ASP.net . 我有以下问题,我将检查“组”,而不访问ASP.net中的某些链接。 Example : 范例:

  • Submenu1 子菜单1

    +Link 1.aspx +链接1.aspx

    +Link 2.aspx +链接2.aspx

  • Submenu2 子菜单2

    +Link 3.aspx +链接3.aspx

    +Link 4.aspx +链接4.aspx

Now i want to checked , if user typing url in web browser, it will deny and redirect a link orther . 现在我要检查,如果用户在Web浏览器中输入url,它将拒绝并重定向链接orther。 Example: User have "group A" only access Link 1.aspx and Link 4.aspx. 示例:用户只有“组A”才能访问链接1.aspx和链接4.aspx。 If user type http://contoso.com/link2.aspx , it will deny and redirect page Default.aspx. 如果用户键入http://contoso.com/link2.aspx ,它将拒绝并重定向页面Default.aspx。 User have "group B" only access Link 2.aspx , if user type http://contoso.com/link1.aspx , it will deny and redirect page Default.aspx,...etc. 用户只有“组B”才能访问Link 2.aspx,如果用户键入http://contoso.com/link1.aspx ,它将拒绝并重定向页面Default.aspx等。 Can you give me for some advice.Thank you. 你能给我一些建议吗,谢谢。

You can do this a number of ways: 您可以通过多种方式执行此操作:

Server side: 服务器端:

1) Use a sitemap and roles see https://msdn.microsoft.com/en-us/library/ms178428(v=vs.140).aspx 2) Descend all your pages from your own BasePage.aspx and in the BasePage.Page_Load() you can do whatever security check that makes sense to restrict whether the user can access that page. 1)使用站点地图和角色,请参阅https://msdn.microsoft.com/zh-cn/library/ms178428(v=vs.140).aspx 2)从您自己的BasePage.aspx和BasePage中降级所有页面.Page_Load()您可以执行任何有意义的安全检查来限制用户是否可以访问该页面。 See https://msdn.microsoft.com/en-us/library/system.web.httpcontext.user%28v=vs.110%29.aspx on how to get your currently logged in user 有关如何获取当前登录用户的信息,请参阅https://msdn.microsoft.com/zh-cn/library/system.web.httpcontext.user%28v=vs.110%29.aspx

Client Side: 客户端:

When the document is ready using jQuery perform an AJAX call to a back end web service to determine if the user can access the requested URL. 使用jQuery准备好文档后,请执行对后端Web服务的AJAX调用,以确定用户是否可以访问所请求的URL。 If not redirect them. 如果没有重定向他们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM