简体   繁体   中英

How to deny link in ASP.net?

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.

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

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. If not redirect them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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