【发布时间】:2012-03-21 03:17:34
【问题描述】:
我正在尝试将 WEB 表单中的 asp.net web api 与 Visual Studio 2010 (sp1) 一起使用 我已经完成了这些步骤http://myrandomykien.blogspot.com/2012/02/simplest-web-api-site-with-nuget.html
当我使用 Visual Studio 开发服务器时它可以工作,但是当我使用 iis 7.5 时,我收到错误 HTTP 404.0 - Not Found。
编辑
这是我的 Global-asax
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = System.Web.Http.RouteParameter.Optional }
);
}
这是api类
public class GreetingController : ApiController
{
public string GetGreeting(string id)
{
return String.Format("Hello {0}", id);
}
}
【问题讨论】:
-
您能提供更多信息吗?现在没什么可做的。
标签: c# asp.net iis-7.5 asp.net-web-api