ASP.NET MVC: Restricting access using url

后端 未结 3 905
耶瑟儿~
耶瑟儿~ 2021-01-21 08:51

The URL for the administration section of my website always starts with Admin/. Is it possible in ASP.NET MVC to restrict access to users by using this part of the

3条回答
  •  盖世英雄少女心
    2021-01-21 09:29

    Found the answer in Steven Sanderson's book, Pro ASP.NET MVC Framework.

    Put the following code in your web.config file.

    
      
        
          
          
          
        
      
    
    

    This means for any URL matching ~/Admin/*, the application will deny access to unauthenticated visitors or any other visitors other than those with the role 'Administrator'.

提交回复
热议问题