老实说,我试过对IIS耍卑鄙的花招,就在我以为我能逃脱的时候,我意识到我的解决办法不起作用。以下是我试图做的:

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

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

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.

4)现在轮到麻烦的部分了……我尝试在Preload方法的末尾从代码中发出GET请求,它工作了。但这个解决方案对我来说很糟糕,尽管它很有效。所以,我尝试了很多东西,我最后尝试的是:

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

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

BUT

应用程序以这种方式启动(预加载和初始化)后,当我想通过Web浏览器访问应用程序时,会发生以下情况:

HTTP错误500.21 -内部服务器错误 “ExtensionlessUrlHandler-Integrated-4.0”在它的模块列表中有一个坏模块“ManagedPipelineHandler”

我想不通。有人能告诉我为什么会发生这种情况以及如何解决吗?

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


当前回答

尝试重新注册ASP。使用aspnet_regiis -i。这对我很管用。

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

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

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

其他回答

如果你在Windows 8/Windows Server 2012和。net 4.5上遇到这个错误,请遵循以下说明: http://www.britishdeveloper.co.uk/2013/01/handler-extensionlessurlhandler.html

点击“打开或关闭Windows功能” 互联网信息服务 然后是万维网服务 然后是应用程序开发特性 然后启用ASP。NET 4.5

这对我来说很管用(尽管Windows Server 2012中的向导和措辞略有不同,但你会发现的)。话虽如此,为什么在通过Web平台安装程序(包括所有依赖项)安装了所有东西之后,这是必要的,这完全超出了我的范围……

对于Windows 10 / Windows Server 2016使用以下命令:

dism /online /enable-feature /featurename:IIS-ASPNET45 /all

使用aspnet_regiis的建议答案在Windows 10(创建者更新及更高版本)或Windows Server 2016上不起作用:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i Microsoft (R) ASP.NET RegIIS version 4.0.30319.0 Administration utility to install and uninstall ASP.NET on the local machine. Copyright (C) Microsoft Corporation. All rights reserved. Start installing ASP.NET (4.0.30319.0). This option is not supported on this version of the operating system. Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog, the Server Manager management tool, or the dism.exe command line tool. For more details please see http://go.microsoft.com/fwlink/?LinkID=216771. Finished installing ASP.NET (4.0.30319.0).

有趣的是,“打开/关闭Windows功能”对话框不允许我取消。net或ASP。NET 4.6,并且只有上面的DISM命令可以工作。不确定featurename是否正确,但它对我有用。

这个错误从上周开始发生在我身上,影响了我机器上现有的网站。我尝试了这里的任何建议都没有运气。最终,我从IIS中完全删除了WebDAV (Windows功能->互联网信息服务->万维网服务->通用HTTP功能-> WebDAV发布)。在此之后,我重新设置了IIS,我的错误最终得到了解决。

我只能猜测是Windows更新引起了这个问题,但我不能确定。

我也遇到了这个问题。我的MVC4应用程序运行在Windows Server 2012 R2和IIS 8.5上。这些贴出来的解决方案对我都没用……通过IIS特性安装缺少的框架可以解决这个问题,但安装总是失败。

我必须使用Web平台安装程序并安装以下包:

这是我自己的帖子,因为这让我花了几个小时。

我在这里和其他地方看到了十几篇类似的关于这个问题和aspnet_regiis修复的帖子。它们不为我工作,aspnet_regiis的行为很奇怪,只是列出选项等。

正如上面用户ryan-anderson所指出的,您不能输入.exe

对于那些对IIS之外的服务器不太熟悉的人,下面是简单步骤。

Find aspnet_regiis in a folder similar to this path. c:\Windows\Microsoft.NET\Framework\v4.0.30319\ Right-click command prompt in the start menu or wherever and tell it to run as administrator. Using the windows "Run" feature just won't work, or didn't for me. Go back to the aspnet_regiis executable. Click-drag it right into the command prompt or copy-paste the address into the command prompt. Remove, if it's there, the .exe at the end. This is key. Add the -i (space minus eye) at the end. Enter.

如果您正确地执行了该操作,您将看到它开始安装asp.net,然后告诉您安装成功。