Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I need to create screen based authorization in web forms..

for eg. I stored in database. 'user1' access following forms form1, form2, form3. . how it reflect in web.config.

i search some sites. they are written directly in web.config <allow user="user1"/>

i no need directly add in web.config.

when i create user the username will add automatically in web.config

What I have tried:

<?xml version="1.0"?>
<configuration>
<system.web>
  <authorization>
    <allow roles="Admin" />
    <deny users="*" />    
  </authorization>
</system.web>
</configuration>
Posted
Updated 15-Jul-17 0:04am
v2
Comments
Atlapure Ambrish 15-Jul-17 10:53am    
As you are already storing accessibility information in database, I am not sure why you need to store it in web.config again. I think you can simply get the role and accessibility information for logged in user and check for authorization.

For example, if you are using asp login control then, do something like this..
<asp:Login ID = "Login1" runat = "server" OnAuthenticate= "ValidateUser">

ValidateUser method is going to fetch data from DB and then you can handle the authorization.
ZurdoDev 15-Jul-17 20:40pm    
I would suggest having each of your pages inherit from a single page. Then in that page you check for access. Otherwise you'll have to list every single page of your app in web.config using a <location> tag.
Vivek.anand34 17-Jul-17 12:40pm    
Why i use web. Config. The user directly type the url and open the screens. Thats why
Vivek.anand34 17-Jul-17 12:41pm    
I restrict in web.config then user cant access via url. it comes again to login page. Thats y am using this.
londhess 18-Jul-17 5:18am    
try to check below link.
https://www.aspsnippets.com/Articles/Implement-Form-based-Authorization-and-Authentication-in-ASPNet.aspx

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