我正在尝试将我的 asp.net mvc Web api 项目迁移到 Visual Studio 2015 预览版。
我没有找到在 Visual Studio 2015 上采用 FilterConfig.cs 代码的方法,因为 2015 版本不支持 global.asax、web.config。
所以我可以把我的过滤器配置、区域配置放在哪里。
最佳答案
您需要在 StartUp 类的ConfigureServices 方法内注册过滤器:
public void ConfigureServices(IServiceCollection services)
{
// Add MVC services to the services container.
services.AddMvc().Configure<MvcOptions>(options =>
{
options.Filters.Add(typeof (MyGlobalFilterAttribute));
});
}
关于asp.net-web-api - Visual Studio 2015 中的 FilterConfig,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29060640/