Fixing ASP.NET MVC 4 Web API 404

Posted on November 5, 2012

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

The Web API started originally as WCF Web API at CodePlex and 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..”

The tutorials and examples for the ASP.NET Web API are 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 the Web 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:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -i

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

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

to the web.config file of my Web API  the routing seems to work fine now.

WebApi 部署后一直返回404的解决办法的更多相关文章

  1. 【转】android中重复连接ble设备导致的连接后直接返回STATE_DISCONNECTED的解决办法---不错不错,重新连接需要花费很长的时间

    原文网址:http://bbs.eeworld.com.cn/thread-438571-1-1.html /*                         * 通过使用if(gatt==null ...

  2. springboot打war包后部署到tomcat后访问返回404错误

    springboot打war包后部署到tomcat后访问返回404错误 1.正常情况下,修改打包方式为war <packaging>war</packaging> 2.启动类继 ...

  3. C# WebAPI中DateTime类型字段在使用微软自带的方法转json格式后默认含T的解决办法

    原文:C# WebAPI中DateTime类型字段在使用微软自带的方法转json格式后默认含T的解决办法 本人新手,在.Net中写WebAPI的时候,当接口返回的json数据含有日期时间类型的字段时, ...

  4. php history.back返回后表单数据丢失的解决办法

    js使用history.back返回表单数据丢失的主要原因就是使用了session_start();的原因,该函数会强制当前页面不被缓存.本文章向码农介绍php history.back返回后表单数据 ...

  5. 关于hexo博客自定义域名后gitment评论系统登陆出现redirect error返回主页的解决办法

    title: 关于hexo博客自定义域名后gitment评论系统登陆出现redirect error返回主页的解决办法 toc: false date: 2018-04-16 22:57:50 cat ...

  6. WPF发布程序后未授予信任的解决办法

    WPF发布程序后未授予信任的解决办法 基于浏览器的WPF应用程序由于需要比较高的操作权限,所以在项目的安全性属性中选择了“这是完全可信的应用程序”选项.可是,在发布部署后,在其他电脑上打开xbap文件 ...

  7. Eclipse中js文件修改后浏览器不能及时更新的解决办法

    项目中js文件修改后浏览器不能及时更新的解决办法 转载:http://www.codeweblog.com/%E9%A1%B9%E7%9B%AE%E4%B8%ADjs%E6%96%87%E4%BB%B ...

  8. MVC3在IIS7.5发布(部署)报403.14错误的解决办法

    MVC3在IIS7.5发布(部署)报403.14错误的解决办法     错误现象: 报403.14 forbidden错误 web服务器被配置为不列出此目录的内容. 解决办法: 检查站点的处理程序映射 ...

  9. CentOS6重启后DNS被还原的解决办法

    CentOS6重启后DNS被还原的解决办法 http://luyx30.blog.51cto.com/1029851/1070765/ centos6.5的64位系统,修改完/etc/sysconfi ...

随机推荐

  1. MYSQL数据库性能调优之四:解决慢查询--索引

    为什么索引能够提高查询速度?没有索引 检索数据的方式是从头到尾一条一条挨着匹配,这是慢的根本原因:索引类型BTREE:二叉树类型,原理图如下:对表创建一个二叉树,记录中间数据的物理磁盘地址,二叉树检索 ...

  2. Codeforces Round #367 (Div. 2) C. Hard problem(DP)

    Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...

  3. iOS开发中的Get请求和POST请求

    //Get请求一般为不涉及到用户的账号密码的网络请求,其中Get请求是等请求内容回来之后,才可以进行下一步的操作 - (void)requestWithGet{ //Get请求: //1.设置请求路径 ...

  4. UVALive 7077 - Song Jiang's rank list(模拟)

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

  5. HDU 5074 Luck Competition (暴力,概率)

    题意:有 n 个人参加比赛,给出n-1个人的成绩,然后要选出一个幸运的人,先把所有的分数求平均数,然后再*2/3,那个不大于这个数,且最接近的数,就是最幸运的, 让你设置最后一个人的分,使他是最幸运的 ...

  6. C#中DllImport用法和路径问题

    DllImport是System.Runtime.InteropServices命名空间下的一个属性类,其功能是提供从非托管DLL导出的函数的必要调用信息.    DllImport属性应用于方法,要 ...

  7. C#取得当前目录 转载

    /获取包含清单的已加载文件的路径或 UNC 位置.         public static string sApplicationPath = Assembly.GetExecutingAssem ...

  8. 结构类模式(二):桥接(Bridge)

    定义 将抽象化(Abstraction)与实现化(Implementation)脱耦,使得二者可以独立地变化. 在软件系统中,某些类型由于自身的逻辑,它具有两个或多个维度的变化,那么如何应对这种“多维 ...

  9. css 关于两栏布局,左边固定,右边自适应

    好几个星期都没写博客了,最近不忙也不闲,稀里糊涂过了两个星期,之前几个月内天天坚持签到.最近也没签到.哈哈,说正事. 今天做东钿互金平台后台页面,昨天做了一个登录页面,业偶碰到了一个难题.等下也要把它 ...

  10. 隐马尔可夫模型(HMM)

    转自:http://blog.csdn.net/likelet/article/details/7056068 隐马尔可夫模型 (Hidden Markov Model,HMM) 最初由 L. E. ...