System.Web.Http.Authorize versus System.Web.Mvc.Authorize

后端 未结 1 1344
面向向阳花
面向向阳花 2020-12-23 16:01

Which Authorize Attribute ?
System.Web.Http.Authorize
System.Web.Mvc.Authorize

using System.Web.Mvc      // or
using System.Web.Http         


        
相关标签:
1条回答
  • 2020-12-23 16:34

    You must use System.Web.Http.Authorize against an ApiController (Web API controller) and System.Web.Mvc.Authorize against a Controller (MVC controller). Since the framework runs the filters as part of the pipeline processing and the controllers expect the right filter to be applied, if you don't use the corresponding filter, authorization will not work.

    0 讨论(0)
提交回复
热议问题