我在.NET 2.0中开发了我的asp.net网站,在其他系统中工作正常。现在,当我抄在我的系统的asp.net网站并运行它比我收到运行时错误:对象引用null- URL重写asp.net
context.CompleteRequest();
:
Object reference not set to an instance of an object.
public class FixURLs : IHttpModule
{
public FixURLs()
{
}
#region IHttpModule Members
public void Dispose()
{
// do nothing
}
public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
context.CompleteRequest();
}
..... some other logic
我在该行获得对象引用错误
我的web.config文件有
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
我该如何解决这个问题?
编辑 编辑注新的代码添加
void context_BeginRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;
if (app.Request.RawUrl.ToLower().Contains("/bikes/default.aspx"))
{
app.Context.RewritePath("BikeInfo.aspx", "", "");
}
else if (app.Request.RawUrl.ToLower().Contains("/bikes/mountainbike.aspx"))
{
app.Context.RewritePath("BikeInfo.aspx", "", "ItemID=1");
}
}
任何帮助,将不胜感激 – Chris 2011-04-02 07:20:46
你在本地IIS或卡西尼开发Web服务器上运行呢? – 2011-04-06 05:54:19
我需要在context_BeginRequest方法中看到代码。你能发布代码吗? – 2011-04-06 06:00:27