如何拒绝ASP.net中的链接 [英] How to deny link in ASP.net
问题描述
大家好。我有以下问题,我会检查群组而不访问ASP.net中的某些链接。
示例:子菜单1
+ Link 1.aspx
+ Link 2.aspx
子菜单2
+ Link 3.aspx
+ Link 4.aspx
现在我想检查一下,如果用户在网页浏览器中输入网址,它会拒绝并重定向一个链接。
例如:用户让A组只能访问Link 1.aspx和Link 4.aspx。如果用户键入http://contoso.com/link2.aspx,它将拒绝并重定向页面Default.aspx。用户有组B只访问Link 2.aspx,如果用户输入http://contoso.com/link1.aspx,它将拒绝并重定向页面Default.aspx,...等。
你能给我一些建议吗。谢谢。
Hello guys.I have problem as follow , i will checked "group" and not access some link in ASP.net .
Example : Submenu1
+Link 1.aspx
+Link 2.aspx
Submenu2
+Link 3.aspx
+Link 4.aspx
Now i want to checked , if user typing url in web browser, it will deny and redirect a link orther .
Example: User have "group A" only access Link 1.aspx and Link 4.aspx. If user type http://contoso.com/link2.aspx , it will deny and redirect page 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.
Can you give me for some advice.Thank you.
推荐答案
加载页面时,在页面加载内,查看上一页带有以下代码的网址。
While loading the page, inside page load, check the previous page URL with the below code.
Request.UrlReferrer
HTTP_REFERER返回一个字符串,其中包含使用标记将请求引用到当前页面的页面的URL。如果页面被重定向,则HTTP_REFERER为空
HTTP_REFERER Returns a string containing the URL of the page that referred the request to the current page using an tag. If the page is redirected, HTTP_REFERER is empty
将URL与您拥有链接的页面进行比较。
因此,如果匹配,则允许。否则,重定向到您想要的位置。
Compare the URL with the page where you have the links.
So, if it matches, then allow. Otherwise, redirect to where ever you want.
这篇关于如何拒绝ASP.net中的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!