请看下面的代码
public class URLRewriter : IHttpModule {
public void Dispose() {
}
public void Init( HttpApplication context ) {
context.BeginRequest += new EventHandler( context_BeginRequest );
}
void context_BeginRequest( object sender, EventArgs e ) {
//code to make custom
URLhttpApplication.Context.Server.Transfer( CustomPath );
}
}
在这里,我IHttpModule
用于进行自定义 URL 重定向。但是在目标页面中设置会话时显示错误。
错误行代码:
HttpContext.Current.Session[USERADMIN] == null
错误信息:
System.NullReferenceException:对象引用未设置为对象的实例。