WebApi 部署后一直返回404的解决办法

摘要:
FixingASP.NETMVC4WebAPI404PostedonNovember5,2012ForaWebServiceprovidingsomeREST-styleURIstoaccessthedata,IdecidedtousetheASP.NETMVC4WebAPI.Oncedeveloped,testedanddeployedIexperiencedamysterious404onmy
Fixing ASP.NET MVC 4 Web API 404
Posted onNovember 5, 2012

For a Web Service providing some REST-style URIs to access the data, I decided to use theASP.NET MVC 4 Web API. Once developed, tested and deployed I experienced a mysterious 404 on my production server.

ASP.NET Web API 404

The Web API started originally asWCF Web API at CodePlexand is finally fully integrated within the latest .NET framework:

“ASP.NET Web API represents the joint efforts of the WCF and ASP.NET teams to create an integrated web API framework. You can get the bits and find articles, tutorials, samples and videos on the new ASP.NET Web API home page. All you have to do is to..”

Thetutorials and examples for the ASP.NET Web APIare overall easy to understand and you probably get access to the technology very quickly. After I set up my first Web API, which worked absolutely perfect on Windows 8, developed using Visual Studio 2012 and tested with the IIS Express, I was not able to get the bits executed on the deployment server. It’s a Windows Server 2008 R2, IIS 7.5 and a whole bunch of stuff installed using theWeb Platform Installer.

Make sure the .NET Framework is installed, probably you missed to install the 4.5 framework on the deployment server. As IIS is set up already, once again it is necessary to register ASP.NET for the latest framework using

C:WindowsMicrosoft.NETFrameworkv4.0.30319>aspnet_regiis.exe -i

Even now, I got the 404. Eventually, I got the tip to check out how therouting of extensionless URLs work in ASP.NET. By adding

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    ...
</system.webServer>

to theweb.configfile of my Web API the routing seems to work fine now.

免责声明:文章转载自《WebApi 部署后一直返回404的解决办法》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇CBAMConvolutional Block Attention Modulelinux —— 编译linux内核下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

c# HttpWebResponse 调用WebApi

public static class WebApiCaller { public static string HttpPost(string url, string body) { try { //ServicePointManager...

webapi获取请求地址的IP

using System.Net.Http; public static class HttpRequestMessageExtensions { private const string HttpContext = "MS_HttpContext"; private const string RemoteEndpointMessa...

Topshelf 搭建轻量级 Windows 服务 + Webapi

创建控制台项目 static void Main(string[] args) { var rc = HostFactory.Run(x => { x.Service<AppServices>(s => {...

Asp.Net WebApi Post请求整理(一)

Asp.Net WebApi+JQuery Ajax的Post请求整理 一、总结 1.WebApi 默认支持Post提交处理,返回的结果为json对象,前台不需要手动反序列化处理。2.WebApi 接收Post提交参数需要指定([FromBody] string name)3.WebApi 中如果只接收一个基础类型参数,不能指定key的名称4.WebAp...

Asp.Net WebAPI Get提交、Post提交处理

1.启用跨域提交 <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add nam...

WebAPi

WebAPi的可视化输出模式(RabbitMQ、消息补偿相关)——所有webapi似乎都缺失的一个功能  最近的工作我在做一个有关于消息发送和接受封装工作。大概流程是这样的,消息中间件是采用rabbitmq,为了保证消息的绝对无丢失,我们需要在发送和接受前对消息进行DB落地。在发送前我会先进行DB的插入,单表插入,所以在性能上也是能接受的,单表插入做了压...