我已经查看了许多可能重复的帖子,但没有运气正确实现它们。我得到的例外是:
'HttpContext.SetSessionStateBehavior'只能在引发'HttpApplication.AcquireRequestState'事件之前调用。
这是我的代码:
public void Page_Load(object sender, System.EventArgs e)
{
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
答案 0 :(得分:0)
修正了:
public void Page_Load(object sender, System.EventArgs e)
{
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
HttpContext.Current.Server.TransferRequest(Request.ApplicationPath);
HttpContext.Current.RewritePath(originalPath, false);
}