简体   繁体   English

在IIS Express上调试ASP.NET时重复的请求

[英]Duplicated requests when debugging ASP.NET on IIS Express

I noticed a strange behavior while debugging an ASP.NET Web Application (.NET 4.6.1). 我在调试ASP.NET Web应用程序(.NET 4.6.1)时发现了一种奇怪的行为。 Whenever an HTTP error occurs (eg 404 or 403) the request get duplicated up to a total of 3 times. 每当发生HTTP错误(例如404或403)时,请求就会被复制到最多3次。

I have tested this singular issue using fiddler, and Intellitrace effectively shows me the three identical requests (even if I send just a single request). 我使用fiddler测试了这个单一的问题,Intellitrace有效地向我显示了三个相同的请求(即使我只发送一个请求)。

提琴手 的IntelliTrace

I can see the effects of this issue because any Owin middleware in the pipeline is invoked three times. 我可以看到这个问题的影响,因为管道中的任何Owin中间件都被调用了三次。 A simple middleware like this: 像这样的简单中间件:

app.Use(async (c, n) =>
{
    Debug.WriteLine("HIT!");
    await n.Invoke();
});

Will print three consecutive "HIT!" 将打印连续三次“HIT!” into the console. 进入控制台。

This happens only if the request generates an error, and not if the request is handled by a middleware (eg not if the middleware responds with a 2XX status code). 这种情况仅在请求生成错误时发生,而不是在请求由中间件处理时发生(例如,如果中间件以2XX状态代码响应则不会)。

What's going on? 这是怎么回事?

I'm running VS2015 and IIS Express 10 on Win10. 我在Win10上运行VS2015和IIS Express 10。

[EDIT] It may be related to my Web.config configuration? [编辑]它可能与我的Web.config配置有关? I'm adding an excerpt from it. 我正在添加一段摘录。

<system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1" enableVersionHeader="false" />
</system.web>
<system.webServer>
    <httpProtocol>
        <customHeaders>
            <clear />
        </customHeaders>
        <redirectHeaders>
            <clear />
        </redirectHeaders>
    </httpProtocol>
    <security>
        <requestFiltering removeServerHeader="true" />
    </security>
    <handlers>
        <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
        <remove name="OPTIONSVerbHandler" />
        <remove name="TRACEVerbHandler" />
        <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

The issue was caused by multiple handlers trying to manage the unhandled request in IIS Express. 该问题是由多个处理程序尝试在IIS Express中管理未处理的请求引起的。 I solved it by removing them in Web.config: 我通过在Web.config中删除它来解决它:

<system.webServer>
    <handlers>
        <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
        <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
        <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
        <remove name="ExtensionlessUrl-Integrated-4.0" />
        <remove name="ExtensionlessUrl-ISAPI-4.0_32bit" />
    </handlers>
</system.webServer>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IIS中的ASP.NET调试 - asp.net debugging in iis 在IIS Express和本地IIS之间进行调试/部署期间,ASP.NET MVC 5 C#URL不同 - ASP.NET MVC 5 C# URL is different during Debugging/Deploying between IIS Express and Local IIS 在使用iis Express进行调试期间配置Asp.Net核心Web API开发环境 - Configure Asp.Net core web api Development environment during debugging with iis express IIS Express Asp.Net正在使用该文件 - The file is in use by IIS Express Asp.Net 针对Active Directory的表单身份验证在IIS Express上有效,但在部署到IIS asp.net时出错 - Form authentication against active directory works on IIS Express but errors when deployed to IIS asp.net ASP.Net Core Web API 适用于 IIS Express,但在部署到 IIS 时不起作用 - ASP.Net Core Web API works on IIS Express, but not working when deployed to IIS asp.net c# 与 iis 一起工作,但不与 ZC7C9B5ABC39FC757817E8A49A1E269 合作 - asp.net c# working with iis express but not with iis local 使用Visual Studio调试ASP.NET时,总是转到IIS Windows网页吗? - Always goto IIS Windows web page when debugging ASP.NET using Visual Studio? 调试 IIS 网站时,ASP.NET Core 2 Web 应用程序未加载用户机密 - ASP.NET Core 2 web application isn't loading user secrets when debugging IIS website ASP.NET Core 2.0 Web API IIS 托管和调试 - ASP.NET Core 2.0 Web API IIS Hosting and Debugging
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM