[英]How to deploy IHttpHandler code to IIS
我有一個用IHttpHandler用c#編寫的簡單處理程序,如何使其在IIS上工作? 我按照http://mvolo.com/developing-iis7-modules-and-handlers-with-the-net-framework/#handler中的教程進行操作,但對我不起作用。
在IIS7中,我的步驟:
我創建一個名為“ SAMPLE”的新網頁
在HandleMappings中,我按下了“添加托管處理程序”
我填充列->請求路徑:* .tm類型:SampleServer.MyHandler名稱:MyHandler
嘗試打開localhost / SampleServer.tm /
我收到此錯誤:MyHandler模塊列表中的“ ManagedPipelineHandler”模塊無效。 錯誤代碼:0x8007000d
Web.сonfig文件自動生成:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="MyHandler" path="*.tm" verb="*" type="SampleServer.MyHandler" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>
我的handler.cs文件:
namespace SampleServer
{
class MyHandler : IHttpHandler
{
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
DateTime dt = DateTime.Now;
context.Response.Write(String.Format("<h1>{0}</h1>", dt.ToLongTimeString()));
}
}
}
終於找到答案了。 這是因為我刪除了以前的IIS,然后安裝了IIS7。 IIS需要配置.NET庫。
在cmd上運行以下命令:
"%windir%\Microsoft.NET\Framework\"YOUR .NET VERSION"\aspnet_regiis.exe" -i
然后,如果您網站的.NET版本低於* .dll文件的版本,請從應用程序池中進行更改。 之后,它運作良好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.