如何在不同的命名空间中路由多个具有相同名称的web api控制器? [英] How to route multiple web api controllers with same name in different namespace?
本文介绍了如何在不同的命名空间中路由多个具有相同名称的web api控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个项目中有3个web api控制器。
一个在根级别,其余两个在两个不同的区域。
如何路由它们?
解决方案
使用以下链接解决这个问题
http:// blogs.msdn.com/b/webdev/archive/2013/03/08/using-namespaces-to-version-web-apis.aspx [ ^ ]
http://aspnet.codeplex.com /SourceControl/latest#Samples/WebApi/NamespaceControllerSelector/NamespaceHttpControllerSelector.cs [ ^ ]
http://devillers.nl/getting-webapi-and-areas-to-play-nicely/ [ ^ ]
命名空间在这里无关紧要...
您所要做的就是在链接中包含区域名称...
@ Html.ActionLink( Action, 控制器, ActionName , new {area = Area })
I have 3 web api controllers in one project.
One is at root level and remaining two are in two different areas.
How to route them ?
解决方案
Solved this by using the following links
http://blogs.msdn.com/b/webdev/archive/2013/03/08/using-namespaces-to-version-web-apis.aspx[^]
http://aspnet.codeplex.com/SourceControl/latest#Samples/WebApi/NamespaceControllerSelector/NamespaceHttpControllerSelector.cs[^]
http://devillers.nl/getting-webapi-and-areas-to-play-nicely/[^]
Namespace is irrelevant here...
All you have to do is include the area name in your link...
@Html.ActionLink("Action", "Controller", "ActionName", new { area = "Area" })
这篇关于如何在不同的命名空间中路由多个具有相同名称的web api控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文