尝试使用我在编译的C#类项目中编写的HTTPModule来记录请求值并扩展第三方CGI购物车。我的模块可以正常使用asp,asp.net,jpg和html请求,但是当我请求store.cgi时,我收到以下错误。我是否必须在IIS7中做一些特殊的事情,或者HTTPModule不能与CGI-BIN中运行的CGI可执行文件一起使用?
服务器错误。无法加载“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; } }
IIS7的Web.config:
...................