C# 处理程序“ExtensionlessUrlHandler-Integrated-4.0”在其模块列表中有一个坏模块“ManagedPipelineHandler”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13162545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 01:49:44  来源:igfitidea点击:

Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list

c#asp.netiisweb-applications

提问by Ivan Peric

To be honest, I've tried to turn a dirty trick on IIS and just when I thought that I was going to get away with it, I realized my workaround doesn't work. Here's what I've tried to do:

老实说,我曾试图在 IIS 上使用一个肮脏的把戏,正当我以为我会逃脱它时,我意识到我的解决方法不起作用。这是我尝试做的:

1) I have ASP.NET application which has Preloaderclass that inherits IProcessHostPreloadClientand does all the heavy initialization in Preloadmethod implementation (application is complex and it's a part of an enormous system, so it requires approximately 2 minutes to establish connections to all necessary services and pre-instantiate some Unity registrations).

1)我有一个 ASP.NET 应用程序,它具有继承IProcessHostPreloadClient 的Preloader类,并在Preload方法实现中完成所有繁重的初始化(应用程序很复杂,它是一个巨大系统的一部分,所以它需要大约 2 分钟来建立到所有必要的连接服务并预先实例化一些 Unity 注册)。

2) I have a lot of work that needs to be done on application shutdown (unsubscribing, disconnecting, disposing,...), and I guess the best place to do it is in *Application_End* method located in Global.asax.

2)我有很多工作需要在应用程序关闭时完成(取消订阅、断开连接、处理……),我想最好的地方是在位于Global.asax 的*Application_End* 方法中。

3) Everything works just fine when I have user activity (first request after the Application Pool that contains aforementioned web application is started will cause *Application_Start* to be called and afterwards *Application_End* is called on Application Pool stop or recycle), but problems occur when there is no user activity and application tries to restart itself after being active for 48 hours (configured requirement). Since there was no requests, application officially didn't get started. Ergo, it can't be gracefully stopped since *Application_End* won't be called.

3)当我有用户活动时一切正常(在包含上述 Web 应用程序的应用程序池启动后的第一个请求将导致 *Application_Start* 被调用,之后 *Application_End* 在应用程序池停止或回收时被调用),但问题当没有用户活动并且应用程序在活动 48 小时后尝试重新启动时发生(配置要求)。由于没有请求,申请正式没有开始。因此,它无法正常停止,因为 *Application_End* 不会被调用。

4) Now comes the messy part... I've tried to make a GET request from code at the end of the Preloadmethod, and it worked. But this solution seemed bad to me, even though it worked. So, I've tried a lot of things, and the last thing I tried was this:

4)现在是混乱的部分......我试图在Preload方法的末尾从代码发出一个 GET 请求,并且它起作用了。但是这个解决方案对我来说似乎很糟糕,即使它有效。所以,我尝试了很多东西,我尝试的最后一件事是:

SimpleWorkerRequest swr = new SimpleWorkerRequest(string.Empty, string.Empty, tw);
HttpRuntime.ProcessRequest(swr);

... and that has done it's purpose. *Application_Start* was called, (I've checked response, it was containing login page that was supposed to be displayed in initial request) and on Application Pool shutdown application ended gracefully by doing necessary work in *Application_End*.

......这已经完成了它的目的。*Application_Start* 被调用,(我检查了响应,它包含应该在初始请求中显示的登录页面)并且在应用程序池关闭时应用程序通过在 *Application_End* 中完成必要的工作而优雅地结束。

BUT

After the application was started (preloaded and initiated) in this manner, this is what happened when I wanted to reach application via Web browser:

以这种方式启动(预加载和启动)应用程序后,这就是我想通过 Web 浏览器访问应用程序时发生的情况:

HTTP Error 500.21 - Internal Server Error Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list

HTTP 错误 500.21 - 内部服务器错误处理程序“ExtensionlessUrlHandler-Integrated-4.0”在其模块列表中有一个错误的模块“ManagedPipelineHandler”

I am unable to figure this out. Can anybody tell me why this happens and how to fix it?

我无法弄清楚这一点。谁能告诉我为什么会发生这种情况以及如何解决它?

If I don't figure this out, I will go back to first solution (sending GET request from code) but this problem will bug me since I don't even have an idea what's wrong.

如果我不明白这一点,我将回到第一个解决方案(从代码发送 GET 请求),但这个问题会让我烦恼,因为我什至不知道出了什么问题。

采纳答案by chue x

The problem

问题

You are using SimpleWorkerRequestin a scenario that it wasn't designed for. You are using it inside of IIS. If you look at the prior MSDN link (emphasis is mine):

您正在使用SimpleWorkerRequest不是为它设计的场景。您正在IIS 内部使用它。如果您查看之前的 MSDN 链接(重点是我的):

Provides a simple implementation of the HttpWorkerRequest abstract class that can be used to host ASP.NET applications outside an Internet Information Services (IIS) application. You can employ SimpleWorkerRequest directly or extend it.

提供 HttpWorkerRequest 抽象类的简单实现,可用于在 Internet 信息服务 (IIS) 应用程序外部托管 ASP.NET 应用程序。您可以直接使用 SimpleWorkerRequest 或扩展它。

Also, if you look at the MSDN documentation for the System.Web.Hosting namespace(SimpleWorkerRequestis in this namespace), you will also see something similar to the above (again, emphasis is mine):

此外,如果您查看System.Web.Hosting 命名空间SimpleWorkerRequest在此命名空间中)的 MSDN 文档,您还会看到与上述类似的内容(同样,重点是我的):

The System.Web.Hosting namespace provides the functionality for hosting ASP.NET applications from managed applications outside Microsoft Internet Information Services (IIS).

System.Web.Hosting 命名空间提供了托管来自Microsoft Internet 信息服务 (IIS) 之外的托管应用程序的 ASP.NET 应用程序的功能。

The solution

解决方案

I would recommend removing the call to SimpleWorkerRequest. Instead, you can use a Microsoft solution to make sure your web site automatically starts up after it recycles. What you need is the Microsoft Application Initialization Module for IIS 7.5. It is not complicated to configure, but you need to understand the exact options. This is why I would also recommend the Application Initialization UI for IIS 7.5. The UI is written by an MSDN blogger.

我建议删除对SimpleWorkerRequest. 相反,您可以使用 Microsoft 解决方案来确保您的网站在回收后自动启动。您需要的是 Microsoft Application Initialization Module for IIS 7.5。配置并不复杂,但您需要了解确切的选项。这就是为什么我还推荐IIS 7.5应用程序初始化 UI。UI 是由 MSDN 博主编写的。

So what exactly does the Microsoft solution do? It does what you are trying to do - IIS sends a "get" request to your website after the application pool is started.

那么微软的解决方案究竟是做什么的呢?它执行您正在尝试执行的操作 - IIS 在应用程序池启动后向您的网站发送“获取”请求。

回答by danijelk

Try to re-register ASP.NET with aspnet_regiis -i. It worked for me.

尝试使用 .NET 重新注册 ASP.NET aspnet_regiis -i。它对我有用。

A likely path for .NET 4 (from elevated command prompt):

.NET 4 的可能路径(来自提升的命令提示符):

c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

http://forums.iis.net/p/1190643/2026401.aspx

http://forums.iis.net/p/1190643/2026401.aspx

回答by Thomas Bratt

I had this problem and found that removing the following folder helped, even with the non-Express edition.Express:

我遇到了这个问题,发现删除以下文件夹有帮助,即使是非 Express edition.Express:

C:\Users\<user>\Documents\IISExpress

C:\Users\<user>\Documents\IISExpress

回答by Zach

If you're running into this error with Windows 8/Windows Server 2012 and .Net 4.5 follow these instructions here: http://www.britishdeveloper.co.uk/2013/01/handler-extensionlessurlhandler.html

如果您在使用 Windows 8/Windows Server 2012 和 .Net 4.5 时遇到此错误,请按照以下说明操作:http: //www.britishdeveloper.co.uk/2013/01/handler-extensionlessurlhandler.html

Go to "turn Windows features on or off"Then Internet Information Services Then World Wide Web Services Then Application Development Features And then enable ASP.NET 4.5

转到“打开或关闭 Windows 功能”,然后是 Internet 信息服务,然后是万维网服务,然后是应用程序开发功能,然后启用 ASP.NET 4.5

This worked for me (although the wizard and wording is a little different in Windows Server 2012, but you'll figure it out). With this being said, why this is necessary after installing everything through the Web Platform Installer including all of the dependencies is completely beyond me...

这对我有用(尽管 Windows Server 2012 中的向导和措辞略有不同,但您会明白的)。话虽如此,为什么在通过 Web 平台安装程序安装所有内容(包括所有依赖项)之后这是必要的,这完全超出了我的理解......

回答by Jonathan

Despite following most of the advice on this page, I was still getting problems on Windows Server 2012. Installing .NET Extensibility 4.5 solved it for me:

尽管遵循此页面上的大部分建议,我仍然在 Windows Server 2012 上遇到问题。安装 .NET Extensibility 4.5 为我解决了这个问题:

Add Roles and Features > Server Roles > Web Server (IIS) > Web Server > Application Development > .NET Extensibility 4.5

Add Roles and Features > Server Roles > Web Server (IIS) > Web Server > Application Development > .NET Extensibility 4.5

回答by jwdaigle

I know this is an oldie, but thought I might add some value. For those of us running Server Core outside of a domain (domain members can just run Server Manager remotely to add/remove features/roles), you have to resort to command lines.

我知道这是一个老歌,但我想我可能会增加一些价值。对于我们这些在域外运行服务器核心的人(域成员可以远程运行服务器管理器来添加/删除功能/角色),您必须求助于命令行。

Powershell users can type "Install-WindowsFeature Web-Asp-Net45"

Powershell 用户可以输入“Install-WindowsFeature Web-Asp-Net45”

That should be equivalent to using server manager.

那应该等同于使用服务器管理器。

回答by user3661608

You could fix it by change the "ExtensionlessUrlHandler-Integrated-4.0" type in iis to System.Web.DefaultHttpHandler

您可以通过将 iis 中的“ExtensionlessUrlHandler-Integrated-4.0”类型更改为 System.Web.DefaultHttpHandler 来修复它

回答by Neshta

This https://stackoverflow.com/a/13266763/1277458works perfectly. But if you have 64-bit operation system use Framework64 instead of Framework in path:

这个https://stackoverflow.com/a/13266763/1277458完美运行。但是如果您有 64 位操作系统,请在路径中使用 Framework64 而不是 Framework:

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

回答by user3896335

Run one of these commands :

运行以下命令之一:

For 32 Bit Windows OS:

对于 32 位 Windows 操作系统:

c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

For 64 Bit Windows OS:

对于 64 位 Windows 操作系统:

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -I

回答by Luke

For me, removing WebDAV from my server caused the application to return a 503 Service UnavailableError message when using PUTor DELETE, so I re-installed it back again. I also tried completely removing .NET Framework 4.5 and reinstalling it and also tried re-registering as suggested but to no avail.

对我来说,从我的服务器中删除 WebDAV 会导致应用程序503 Service Unavailable在使用PUT或时返回错误消息DELETE,因此我重新重新安装了它。我还尝试完全删除 .NET Framework 4.5 并重新安装它,还尝试按照建议重新注册但无济于事。

I was able to fix this by disabling WebDAV for the individualapplication pool, this stopped the 'bad module' error when using PUTor DELETE.

我能够通过为单个应用程序池禁用 WebDAV 来解决这个问题,这在使用PUT或时停止了“坏模块”错误DELETE

Disable WebDAV for Individual App Pool:

为单个应用程序池禁用 WebDAV:

  1. Click the affected application pool
  2. Find WebDAV Authoring Toolsin the list
  3. Click to open it
  4. Click Disable WebDAVin the top right.
  1. 单击受影响的应用程序池
  2. WebDAV Authoring Tools在列表中查找
  3. 点击打开
  4. 点击Disable WebDAV右上角的。

Ta daaaa!

天啊!

I still left the remove items in my web.configfile.

我仍然在我的web.config文件中留下了删除项目。

 <system.webServer>
    <modules>
      <remove name="WebDAVModule"/>
    </modules>
    <handlers>
      <remove name="WebDAV" />
    </handlers>
 <system.webServer>

This linkis where I found the instructions but it's not very clear.

这个链接是我找到说明的地方,但不是很清楚。