【发布时间】:2014-08-08 18:09:05
【问题描述】:
我有与 MVC 网站一起使用的服务器,并在同一个 web.config 文件上公开了 REST API。
一切都很好,但突然休息 API 开始返回:
找不到资源
我深入搜索了这个问题,没有发现任何可能导致这个问题的代码更改。其他相同代码版本的服务器运行正常。
我使用了 RouteDebug 工具,得到的输出是其余 API 的路由已损坏。 什么可能导致它,我该如何解决它?
路由在 global.asax.cs 文件中如下:
routes.Add(new ServiceRoute("MyServices", new WebServiceHostFactory(), typeof(MyServicesType)));
Web.config:
<service name="namespace.MyServices">
<endpoint address="mex" binding="webHttpBinding" bindingConfiguration="webHttpBinding" behaviorConfiguration="REST" contract="namespace.IMyServices" />
</service>
</services>
非常感谢, N.
【问题讨论】:
-
您是否在 RouteConfig.RegisterRoutes 之前在 App 启动时注册您的 WebApiConfig?如果没有,您可以尝试交换它们,看看是否有区别?
-
您好,感谢您的回复。我在 Global.asax.cs 中的调用是这样的:“AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes);”我看不到配置文件的注册位置,但我认为是 IIS 服务在应用程序代码实际启动之前执行此操作。
标签: c# asp.net-mvc wcf rest routing