Web Application Authentication

I have two questions about authenticating an intranet website and how to do it.

  • I need the first page that the user comes to in order to be the login page. I could swear there is a tag, something like [Authorize] that you put your C # code that did it for you, but I can no longer find it. Right now, the first page is my dafault.aspx. I turned on Windows authentication in the web.config file and logged in automatically. So this works, but I want the user to be logged in as above. What should I do?
  • I want people in a particular group to have access. How to add additional verification?
+4
source share
4 answers
+1
source

In your web.config file you need to add the following

<authentication mode="Forms"> <forms loginUrl="YOUR LOGIN PAGE!!" timeout="2880" /> </authentication> 

in the <system.web /> .

This will force the user to authenticate for this site.

The [Authorize] attribute is used to require user authentication (for example, you have posed your question), BUT !! for MVC applications only http://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute.aspx

With MVC, you can also use the [RequiresAuthentication(Roles = "admin")] attribute, which will give you control over which clips have access to endpoints.

I would seriously consider MVC

+2
source

Here's a guide to setting up authentication on your site: http://www.4guysfromrolla.com/webtech/110701-1.shtml

Part 2 contains meat.

+1
source

Thanks for the great contribution. They made me go in the right direction, and then the client decided to change direction. They want to have autorun if they are in the correct group, otherwise error messages and error messages are displayed. Form authentication would work as described.

0
source

Source: https://habr.com/ru/post/1388398/


All Articles