Answer the question
In order to leave comments, you need to log in
How to make authorization by roles?
Created a standard ASP.NET web application. A couple of pages + authorization are already being created there.
How to do it: so that when you open the site, a window with authorization opens, and then goes to the main site.
I did the following. Created a Web.sitemap and wrote this code there:
<siteMapNode url="Contact.aspx" title="Контакт" description="" roles="User" />
<location path="Contact.aspx">
<system.web>
<authorization>
<allow roles="User"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
Answer the question
In order to leave comments, you need to log in
I found a solution! The point is. We create an ASP.NET web application with built-in authorization from Microsoft (not a blank web application). Then we go to the top of the Visual Studio screen, and there we see the "Project" button (Someone may call it Web Project), click and select the "ASP.NET Configuration" item. Your browser will open with the ASP.NET Web Site Administration Tool page. There we go to the "Security" tab, and there will be the "Roles" field in the center, click "Enable". After that, the roles will work. Now click on "Create and manage roles", and add the desired role. For example "Admin". After that, you can safely register on your site, and return to these settings again. There you can find your registered account by name.
Attention! Nothing then needs to be changed or added to the SQL database, which was automatically created, and about which I wrote at the beginning, I made a mistake then. You just need to configure everything through the "Web site administration tool". Thanks to everyone who tried to help. And I hope this information helps someone.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question