尝试使用我在编译的 C#类项目中编写的 HTTPModule 来记录请求值并扩展第三方 CGI 购物车。我的模块可以正常使用 asp,asp.net,jpg 和 html 请求,但是当我请求 store.cgi 时,我收到以下错误。我是否必须在 IIS7 中做一些特殊的事情,或者 HTTPModule 不能与 CGI-BIN 中运行的 CGI 可执行文件一起使用?
'/cgi-bin'应用程序中的服务器错误。
无法加载“IISWatcher.WatchRequests”类型。描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.Web.HttpException:无法加载类型“IISWatcher.WatchRequests”。
源代码:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Messaging;
namespace IISWatcher
{
public class WatchRequests : IHttpModule
{
public void Init(System.Web.HttpApplication app)
{
app.BeginRequest += new EventHandler(app_BeginRequest);
app.EndRequest += new EventHandler(app_EndRequest);
}
void app_EndRequest(object sender, EventArgs e)
{
//HttpApplication app = (HttpApplication)sender;
}
void app_BeginRequest(object sender, EventArgs e)
{
string strReturn = "\r\n";
HttpApplication app = (HttpApplication)sender;
string strAddress = app.Request.UserHostAddress;
string strUrl = app.Request.Url.AbsoluteUri;
string strQS = app.Request.QueryString.ToString();
RequestInfo ri = new RequestInfo();
System.Diagnostics.EventLog.WriteEntry("HttpModule",
"IpAddress: " + strAddress + strReturn + "URL:" + strUrl);
System.Messaging.MessageQueue msq = new MessageQueue(@".\private$\HttpModuleQueue");
ri.AbsoluteUri = strUrl;
ri.IPAddress = strAddress;
ri.QueryString = strQS;
msq.Send(ri);
}
public void Dispose()
{
}
}
public class RequestInfo
{
public string IPAddress;
public string AbsoluteUri;
public string QueryString;
}
}
Web.config for IIS7:
...................