httpModule的代码如下:
using System;
using System.Web;
namespace add_timestamp_module
{
public class add_timestamp_module : IHttpModule
{
public void Init(HttpApplication application)
{
application.AcquireRequestState += (new
EventHandler(this.Application_AcquireRequestState));
}
private void Application_AcquireRequestState (Object source,
EventArgs e)
{
HttpApplication Application = (HttpApplication)source;
string tiamestamp= DateTime.UtcNow.ToString();
Application.Context.Request.UserAgent=tiamestamp;
}
public void Dispose()
{
}
}
}
生成解决方案时,出现如下错误:
无法对属性或索引器“System.Web.HttpRequest.UserAgent”赋值 -- 它是只读的
我目的是想在Application.Context.Request里面的属性加上一个时间刻,以便到web service里访问到,而且是要在服务器端在SOAP消息请求被WEB服务程序处理之前加注,所以我选择用httpmodule的办法,路过的大鸟请赐教,万分感激!!!!!!!!