自定义支持命名空间后,代码为微软给的,见链接 http://aspnet.codeplex.com/SourceControl/changeset/view/dd207952fa86#Samples/WebApi/NamespaceControllerSelector/NamespaceHttpControllerSelector.cs
再使用特性路由的时候,会发生取不到命名空间、控制器名称,但能取到传递的参数信息。
1 public HttpControllerDescriptor SelectController(HttpRequestMessage request) 2 3 { 4 IHttpRouteData routeData = request.GetRouteData(); 5 if (routeData == null) 6 { 7 throw new HttpResponseException(HttpStatusCode.NotFound); 8 } 9 10 // Get the namespace and controller variables from the route data. 11 string namespaceName = GetRouteVariable<string>(routeData, NamespaceKey); 12 if (namespaceName == null) 13 { 14 throw new HttpResponseException(HttpStatusCode.NotFound); 15 } 16 17 string controllerName = GetRouteVariable<string>(routeData, ControllerKey); 18 if (controllerName == null) 19 { 20 throw new HttpResponseException(HttpStatusCode.NotFound); 21 } 22 23 // Find a matching controller. 24 string key = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", namespaceName, controllerName); 25 }
请问有什么办法吗?
没有人来帮忙解决吗 ?