Questions tagged «action-filter»

6
为什么我的ASP.NET Web API ActionFilterAttribute OnActionExecuting无法启动?
我正在尝试实施此处看到的内容:http : //www.piotrwalat.net/nhibernate-session-management-in-asp-net-web-api/但我的出现了问题NhSessionManagementAttribute。 我已在自己的节点上设置了断点,OnActionExecuting(HttpActionContext actionContext)以查看是否曾经调用过该函数-事实并非如此。 我仔细检查了global.asax.cs文件并发现我实际上是在向注册ActionFilter: GlobalConfiguration.Configuration.Filters.Add(new NhSessionManagementAttribute()); 我还用无效的属性装饰了控制器类本身及其动作: public class ClientsController : ApiController { static readonly ClientRepository repository = new ClientRepository(); [NhSessionManagement] public IEnumerable<Client> GetAllClients() { return repository.GetAll(); } [NhSessionManagement] public Client GetClient(int id) { Client client = repository.Get(id); if (client == null) { throw new HttpResponseException( new HttpResponseMessage(HttpStatusCode.NotFound) …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.