C# WebApi没有';你不能出版吗?

C# WebApi没有';你不能出版吗?,c#,asp.net-mvc-4,iis-7,asp.net-web-api,C#,Asp.net Mvc 4,Iis 7,Asp.net Web Api,我目前有两个控制器。一个是MVC,另一个是WebApi控制器。 我已使用以下设置轻松地在IIS服务器上发布了这两个版本: WebApiConfig: config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optiona

我目前有两个控制器。一个是MVC,另一个是WebApi控制器。 我已使用以下设置轻松地在IIS服务器上发布了这两个版本:

WebApiConfig:

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
路线图:

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "MVCControllerName", action = "MVCControllerName", id = UrlParameter.Optional }
        );
现在我添加了另一个WebApi控制器,但发布时,Web服务器会显示:

未找到与请求URI匹配的HTTP资源

其他控制器的实现

    public void Get(int id, string text)
    {
         // something simply gets commited to the DB
    }
另外,在发布时也发生了一些奇怪的事情。。。我已经从解决方案中删除了第一个WebApi控制器,但由于发布时的某些原因,我仍然可以通过HTTP GET请求调用该WebApi!即使它不见了

OTOH,它在调试模式下工作正常

这是怎么回事


编辑:问题似乎不在我的代码中,而是在VS的发布功能中。到目前为止,它一直有效。我必须手动将文件复制到服务器上,这不是所谓的“一键发布”的目的。其他类似的SO问题似乎表明这是一个VS错误,在SP2中仍未修复。

您如何发布它?看起来是一个路由问题,routeTemplate:“api/{controller}?{id}”只接受id为的路由,您无法使用此配置访问双参数控制器,添加“api/{controller}/{id}/{text}”还有。@Jonesy我正在使用VS发布功能,通过web服务器上的FTP替换文件。@Fals No dice。我在尝试调用新的webapi时仍然得到了404。这是一个优先顺序,将此路由放在第一位!
    public void Get(int id, string text)
    {
         // something simply gets commited to the DB
    }