我在为IIS创建新处理程序(我尝试过的第一个处理程序时遇到问题。我的设置是:
Windows Server 2012上的IISWindows 10上的Visual Studio 2017(当前正在运行php网站)
这是mt处理程序的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace ProvaIISdotNET
{
class myHandler : IHttpHandler
{
#region IHttpHandler Members
public bool IsReusable {
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
context.Response.Write("<html><body>Hi everybody!</body></html>");
}
#endregion
}
}
在Visual Studio上,我做了一个新的可视C#项目>类库(.Net Framework)
我想念什么?
这就是我部署处理程序的方式。1.创建一个名为“ ProvaIISdotNET”的组装项目。
2。我删除默认的class.cs并创建了myHandler.cs
3。我复制了这样的代码。由于VS发出了system.linq的警报,因此在这里不需要它,因此我将其删除。
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace ProvaIISdotNET
{
class myHandler : IHttpHandler
{
#region IHttpHandler Members
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
context.Response.Write("<html><body>Hi everybody!</body></html>");
}
#endregion
}
}
我将发行版.dll复制到我站点的根bin文件夹D:\ mysite \ bin(请确保将程序集放在根bin文件夹中]]] >>
我将此添加到根web.config system.webserver \ handlers部分。请确保在type属性的末尾没有空格“”。
<handlers>
<add name="myhandler" path="*" verb="GET" type="ProvaIISdotNET.myHandler" />
</handlers>
6。我回收了应用程序池。
现在它在我这边工作