HTTP 404页在IIS 7.5托管的网页API未找到 [英] HTTP 404 Page Not Found in Web Api hosted in IIS 7.5

查看:299
本文介绍了HTTP 404页在IIS 7.5托管的网页API未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web API应用程序。它的工作原理,当我测试它使用VS 2010的调试开发服务器非常清楚。但我现在部署它IIS 7.5和我正在试图访问应用程序时,一个HTTP 404错误。

下面是我的web.config

<?XML版本=1.0编码=UTF-8&GT?;
<结构>
  <&是connectionStrings GT;
    <添加名称=DefaultConnection的connectionString =数据源= \\ SQLEX $ P $干燥综合征;初始目录= ASPNET-FlowGearProxy-20123141219;集成安全性=真的providerName =System.Data.SqlClient的/>
  < /&是connectionStrings GT;
  <&的appSettings GT;
    <添加键=网页:版本值=2.0.0.0/>
    <添加键=网页:启用VALUE =真/>
    <添加关键=preserveLoginUrlVALUE =真/>
    <添加键=ClientValidationEnabledVALUE =真/>
    <添加键=UnobtrusiveJavaScriptEnabledVALUE =真/>
  < /的appSettings>
  <&的System.Web GT;
    <编译调试=真targetFramework =4.0/>
    <身份验证模式=表格>
      <形式loginUrl =〜/帐号/登录超时=2880/>
    < /认证>
    <网页和GT;
      <&命名空间GT;
        <添加命名空间=System.Web.Helpers/>
        <添加命名空间=System.Web.Mvc/>
        <添加命名空间=System.Web.Mvc.Ajax/>
        <添加命名空间=System.Web.Mvc.Html/>
        <添加命名空间=System.Web.Routing/>
        <添加命名空间=System.Web.WebPages/>
      < /命名空间>
    < /页>
  < /system.web>
  < system.webServer>
    <验证validateIntegratedModeConfiguration =FALSE/>
    <模块runAllManagedModulesForAllRequests =真/>
  < /system.webServer>
< /结构>


解决方案

我这个苦苦挣扎也是如此。幸运的是,史蒂夫米凯洛蒂记载,为我工作的解决方案<一href=\"http://geekswithblogs.net/michelotti/archive/2011/05/28/resolve-404-in-iis-ex$p$pss-for-put-and-delete-verbs.aspx\">here.

在一天结束的时候,我所有启用的动词(动词=*)的ExtensionlessUrlHandler - 集成 - 4.0处理程序在我的web配置。

 &LT; system.webServer&GT;
    &LT;验证validateIntegratedModeConfiguration =FALSE/&GT;
    &LT;模块runAllManagedModulesForAllRequests =真/&GT;
        &LT;&处理GT;
            &LT;清除NAME =ExtensionlessUrlHandler - 集成 - 4.0/&GT;
            &LT;添加名称=ExtensionlessUrlHandler - 集成 - 4.0PATH =*。动词=*TYPE =System.Web.Handlers.TransferRequestHandler= resourceType为未指定requireAccess =脚本preCondition =integratedMode,runtimeVersionv4.0/&GT;
        &LT; /处理器&GT;
&LT; /system.webServer>

另一些人指出,有WebDAV的启用导致的问题。幸运的是,我没有碰到这个问题为好。

I have a Web Api application. It works perfectly well when I tested it using the VS 2010 debugging dev server. But I now deployed it to IIS 7.5 and I am getting a HTTP 404 error when trying to access the application.

Here is my web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-FlowGearProxy-20123141219;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="true" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
</configuration>

解决方案

I was struggling with this as well. Fortunately, Steve Michelotti documented a solution that worked for me here.

At the end of the day, I enabled all verbs (verb="*") to the ExtensionlessUrlHandler-Integrated-4.0 handler in my web config.

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
        <handlers>
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
            <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
</system.webServer>

Others have pointed out that having WebDAV enabled causes issues. Fortunately, I did not run into that issue as well.

这篇关于HTTP 404页在IIS 7.5托管的网页API未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆