Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
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.
Posted

1 solution

While loading the page, inside page load, check the previous page URL with the below code.
C#
Request.UrlReferrer

Quote:
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
Compare the URL with the page where you have the links.

So, if it matches, then allow. Otherwise, redirect to where ever you want.
 
Share this answer
 
Comments
Suvabrata Roy 7-May-15 1:13am    
I think user is asking for something else.
I think :
He is asking for Group wise menu permission
Yes, seems like. But still unclear. Where the group thing is stored? Anyways, let him reply to my answer first. We can take that forward after that.
Suvabrata Roy 7-May-15 7:14am    
Sure...
headshot9x 7-May-15 21:15pm    
Hi Tadit Dash,I think you wrong this issue . NOTE : I want to check in a link page , I think i should check in Page_Load of page .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.
Please read it clearly.
Thank you
Okay, so check this condition on Page Load and redirect accordingly.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900