Allow users to access specific locations in ASP

We will discuss on how we can allow specific users to access from specific locations.

Some projects require to set permissions to access specific locations within your project.  In this article I will show you in a step-by-step guide how to restrict access to users in ASP.Net

  1. Open your ASP project

2. In the file explorer, open the web.config file of your project and find the <System> tag.

open-webconfig-Allow-users-to-access-specific-locations-in-ASP

3. Add the <location path = -> tag with the specific file. Then, add the users that will have access to the location specified

edit-code-Allow-users-to-access-specific-locations-in-ASP

====================

<location path=”MonthlyReports.aspx”>
<system.web>
<authorization>
<deny users=”?” />
<allow users=”Reports\user2, Reports\user3, Reports\userChief” />
<deny users=”*” />
</authorization>
</system.web>
</location>

====================

4. The code above specifies the users who have access to the specified location. This is important when projects are large and are developed by different users. It is important to establish the type of authentication, in this code that I’ve used is authentication mode to Windows.

5. And that’s it! You are done in defining access to users. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *