asp.net-mvc-custom-filter

C# API Controller Custom Filter with HttpActionContext Redirect to controller?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-17 05:27:29
问题 Is there a way to create a custom filter with an API controller to redirect to a MVC controller? After looking around a bit his is what i have. public class APIHasOneOfThesePermissions : ActionFilterAttribute { protected UserManager<ApplicationUser> UserManager { get; set; } private SAMPortal.DAL.SAMPortalContext db = new DAL.SAMPortalContext(); public string[] Permissions { get; set; } public APIHasOneOfThesePermissions(string[] Permissions) { this.UserManager = new UserManager

C# API Controller Custom Filter with HttpActionContext Redirect to controller?

六眼飞鱼酱① 提交于 2020-01-17 05:27:04
问题 Is there a way to create a custom filter with an API controller to redirect to a MVC controller? After looking around a bit his is what i have. public class APIHasOneOfThesePermissions : ActionFilterAttribute { protected UserManager<ApplicationUser> UserManager { get; set; } private SAMPortal.DAL.SAMPortalContext db = new DAL.SAMPortalContext(); public string[] Permissions { get; set; } public APIHasOneOfThesePermissions(string[] Permissions) { this.UserManager = new UserManager

asp.net MVC Custom Filters [RESTAuthorize] is ignored

别说谁变了你拦得住时间么 提交于 2019-12-14 03:57:02
问题 The [RESTAuthorization] is being ignored and instead jump into the code to Get all the Country without checking for the Rest Authorization filter. Here is the code for RESTAuthorization using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using MyWebsite.Repository; namespace MyWebsite.API.Attributes { public class RESTAuthorizeAttribute : AuthorizeAttribute { private ISecurityRepository _repository; public RESTAuthorizeAttribute() : this