【发布时间】:2016-05-29 23:35:17
【问题描述】:
把我逼疯了,希望有人能帮助我。
使用 WebAPI 我可以做这样的事情
public class AuthenticationMessageHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage>SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
try
{
var config = GlobalConfiguration.Configuration;
var controllerSelector = new DefaultHttpControllerSelector(config);
var descriptor = controllerSelector.SelectController(request);
var atts = descriptor.GetCustomAttributes<IgnoreValidationAttribute>();
这让我有了我的特质,我很开心,会笑,一切都很好。
但是
使用属性路由,相信是问题所在,使用上面的代码还是替换
var config = GlobalConfiguration.Configuration;
与
var config = request.GetConfiguration();
我得到空异常,我不那么开心和笑脸。当我被难住时,一些很棒的人能给我一些解决这个问题的建议吗?
提前致谢!
【问题讨论】:
标签: asp.net-web-api2 owin self-hosting attributerouting