Authorization with Session variables in asp net mvc 5

后端 未结 2 867
暗喜
暗喜 2021-01-06 08:50

So my project requirements changed and now I think I need to build my own action filter.

So, this is my current login controller:

 public class Login         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-06 09:45

    Since your attribute is added to the FilterConfig, it will apply to ALL actions. So when you navigate to your MainPage/Default action it will be applying the filter and redirecting you to your MainPage/Default action (and so on...).

    You will either need to:

    • remove it from the FilterConfig and apply it to the appropriate actions / controllers
    • or add an extra check in the filter so that it doesn't redirect on certain routes

提交回复
热议问题