ASP.NET MVC 2 和 ASP.NET MVC 2 IIS:HTTP 500.24 favicon.ico 错误

发布于 2024-10-01 07:15:06 字数 4804 浏览 9 评论 0 原文

我的 ASP.NET MVC 2 应用程序有一些奇怪的行为。

我使用 IIS 7.5、Windows 身份验证和 ASP.NET 模拟来加载网页。

经过多次搜索,我没有找到一个很好的方法来摆脱每次页面加载时不断收到的 500.24 请求(根目录中的 favicon.ico 会触发此请求):

Fiddler

我看过一些文章,例如 这个那个 但这似乎并不能解决我的问题。我需要这些设置才能让我的应用程序在这里工作:.NET 4 Framework 集成模式管道、Windows 身份验证和 ASP.NET 模拟。

这是我的 web.config 的简化版本,如果它可以帮助任何人(当然,出于安全原因我已经删除了连接字符串..)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <customErrors mode="Off" />
    <identity impersonate="true" />
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <authentication mode="Windows">
      <!-- roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" / -->
      <!-- forms loginUrl="~/Account/LogOn" timeout="2880" / -->
    </authentication>
    <membership>
      <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/Globe" />
      </providers>
    </membership>
    <profile>
      <providers>
        <clear />
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/Globe" />
      </providers>
    </profile>
    <roleManager enabled="false">
      <providers>
        <clear />
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/Globe" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/Globe" />
      </providers>
    </roleManager>
    <pages>
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="X-UA-Compatible" value="IE=edge" />
      </customHeaders>
    </httpProtocol>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
    </modules>
    <security>
      <requestFiltering>
        <verbs>
          <add verb="PUT" allowed="true" />
          <add verb="DELETE" allowed="true" />
        </verbs>
      </requestFiltering>
    </security>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>
</configuration>

我的应用程序正在运行,favicon.ico 正在加载,我只是想知道为什么它确实会在每个请求上触发 500.24 (当然,也许是 Fiddler 无法验证自身并导致 500.24 HTTP 错误,但是当它正常时,它会触发 401.2 - 未经授权......)

I have a little weird behavior with my ASP.NET MVC 2 application.

I'm using IIS 7.5, Windows Authentication and ASP.NET Impersonation for my webpage to load.

After several searches, I didn't found a nice way to get rid of the 500.24 Request that I keep getting on every page load (The favicon.ico at the root directory triggers this) :

Fiddler

I've looked at some articles like this one or that one but this doesn't seems to solve my issue. I need these settings on for my application to work here : .NET 4 Framework Integrated Mode pipeline, Windows Authentification and ASP.NET Impersonation.

Here's a simplified version of my web.config, if it can help anyone (of course, I've removed the connections strings for security reasons..)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <customErrors mode="Off" />
    <identity impersonate="true" />
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <authentication mode="Windows">
      <!-- roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" / -->
      <!-- forms loginUrl="~/Account/LogOn" timeout="2880" / -->
    </authentication>
    <membership>
      <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/Globe" />
      </providers>
    </membership>
    <profile>
      <providers>
        <clear />
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/Globe" />
      </providers>
    </profile>
    <roleManager enabled="false">
      <providers>
        <clear />
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/Globe" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/Globe" />
      </providers>
    </roleManager>
    <pages>
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="X-UA-Compatible" value="IE=edge" />
      </customHeaders>
    </httpProtocol>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
    </modules>
    <security>
      <requestFiltering>
        <verbs>
          <add verb="PUT" allowed="true" />
          <add verb="DELETE" allowed="true" />
        </verbs>
      </requestFiltering>
    </security>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>
</configuration>

My application IS working, the favicon.ico IS loading, I'm just wondering why it does fires a 500.24 on every request (Of course, maybe it's Fiddler who can't authenticate itself and causes de 500.24 HTTP Error, but when it does normally it triggers a 401.2 - Unauthorized instead...)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

久伴你 2024-10-08 07:15:06

我的猜测是 favicon.ico 要么在不同的应用程序池中运行,要么网站根目录中的 web.config 有问题。
所以:
1) 检查站点根目录(/favicon.ico 所在目录)是否包含 web.config。如果是,则检查是否正在设置 system.web/httpModule、httpHandler、system.web/identity(模拟)或类似的内容,并且应用程序池是否正在集成模式下运行。

因此,您需要做的是删除有问题的 httpmodule/httphandler/impersonate 设置,或者将应用程序池更改为经典运行,或者添加您的站点包含的相同配置,即

My guess is that favicon.ico is either running in a different application pool, or there is a web.config in the root of the site that has issues.
So:
1) Check to see if the root of the site (the directory where /favicon.ico lives) includes a web.config. If it does, then check to see if it is setting a system.web/httpModule, or httpHandler, or system.web/identity (impersonate) or something like that, and the application pool is running in integrated mode.

So what you need to do is either remove the offending httpmodule/httphandler/impersonate setting, or change the application pool to run as classic, or add the same configuration your site includes which is <validation validateIntegratedModeConfiguration="false" />

预谋 2024-10-08 07:15:06

卡洛斯·阿格说的话。廉价的修复方法可能是将图标移至受影响的应用程序中,而不是向树上吠叫。

What CarlosAg said. Cheap fix might be to move the favicon into the offended app rather than barking up the tree.

折戟 2024-10-08 07:15:06

我确实找到了问题的答案 =)

你肯定会嘲笑我的.. =P

好吧,答案的一部分是 在 CarlosAg 指出的 C:\inetpub\wwwroot 中,但另一部分是我只是忘记添加 " type="image/x-icon" /> 到我的 ASP.NET MVC 2 应用程序中的 Site.Master 文件。由于 Chrome 和 IE 确实会查看 favicon.ico 的根目录,因此它似乎可以工作,但直到现在我才注意到 Firefox 没有加载 favicon。

现在,每个浏览器都会加载该图标,并且 Fiddler 中不会发送 500.24 HTTP 请求。

谢谢 ! =)

I did find the answer to my problem =)

You're gonna laugh at me, for sure.. =P

Well, part of the answer is the <validation validateIntegratedModeConfiguration="false" /> in the C:\inetpub\wwwroot that CarlosAg pointed out, but the other part was that I simply forgot to add the <link rel="icon" href="<%: Url.Content("~/favicon.ico")%>" type="image/x-icon" /> to my Site.Master file in my ASP.NET MVC 2 Application. Since Chrome and IE does look at the root directory for a favicon.ico, it appeared to work, but I didn't notice until now that Firefox wasn't loading up the favicon.

Now the favicon loads on every browser, and there is no 500.24 HTTP Request sent over in Fiddler.

Thanks ! =)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文