ASP.NET MVC: Restricting access using url

后端 未结 3 915
耶瑟儿~
耶瑟儿~ 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:36

    That will work but you then tie the authorisation to your current Routing model. The beauty of authorising the Actions is that it abstracts the functionality (which is, actually, what you want to control) from the url structure that you are currently using.

    It also means that you can Unit Test this functionality.

提交回复
热议问题