我写了一个类
public class CMISproHttpModule : IHttpModule
{
public CMISproHttpModule()
{
}
public String ModuleName
{
get { return "CMISproHttpModule"; }
} public void Init(HttpApplication application)
{
application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
application.EndRequest += (new EventHandler(this.Application_EndRequest));
} private void Application_BeginRequest(Object source,
EventArgs e)
{
// Create HttpApplication and HttpContext objects to access
// request and response properties.
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
string ReqURL=context.Request.Url.ToString();
if(ReqURL.IndexOf("RunModule.aspx")>=0)
{
if (hasKey(context.Request.QueryString,"MDID"))
{
string UMIDString = context.Request.QueryString["MDID"].ToString().Trim();
double aMDID = 0;
aMDID = Convert.ToDouble(UMIDString);
string ServerPath = context.Server.MapPath(@"~\bin");
string sUrl = Mac.RunModuleP(aMDID, ServerPath);
if (sUrl == "")
{
context.Server.Transfer("~/FrameWork/NoLeave.aspx", false);
return;
}
context.Server.Transfer(sUrl, true);
}
else
{
context.Server.Transfer("~/FrameWork/NoLeave.aspx", false);
}
}
else
{
} }
private bool hasKey(System.Collections.Specialized.NameValueCollection nv,string pKey)
{
return true;
}
private void Application_EndRequest(Object source, EventArgs e)
{ } public void Dispose()
{
}目的是实现通过调用RunModule来定位页面。我在目的页面中使用了ASP.net AJAX重定向已经可以实现,但是在打开的页面中点击功能时抱错。
当点击一次的按钮的时候一切正常,但是再点击其他按钮的时候就报 404错误,我用web development tools跟踪了一下,发现页面的路径发生了变化定向到了我所打开的文件路径。例如:
第一次点击 请求地址为: localhost/website/components/MK1/MKWH.aspx?ID=111
第二次点击 请求地址变成:localhost/website/FrameWork/MKWH.aspx?ID=111请问有什么方法能不让重定向的时候改变其地址
public class CMISproHttpModule : IHttpModule
{
public CMISproHttpModule()
{
}
public String ModuleName
{
get { return "CMISproHttpModule"; }
} public void Init(HttpApplication application)
{
application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
application.EndRequest += (new EventHandler(this.Application_EndRequest));
} private void Application_BeginRequest(Object source,
EventArgs e)
{
// Create HttpApplication and HttpContext objects to access
// request and response properties.
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
string ReqURL=context.Request.Url.ToString();
if(ReqURL.IndexOf("RunModule.aspx")>=0)
{
if (hasKey(context.Request.QueryString,"MDID"))
{
string UMIDString = context.Request.QueryString["MDID"].ToString().Trim();
double aMDID = 0;
aMDID = Convert.ToDouble(UMIDString);
string ServerPath = context.Server.MapPath(@"~\bin");
string sUrl = Mac.RunModuleP(aMDID, ServerPath);
if (sUrl == "")
{
context.Server.Transfer("~/FrameWork/NoLeave.aspx", false);
return;
}
context.Server.Transfer(sUrl, true);
}
else
{
context.Server.Transfer("~/FrameWork/NoLeave.aspx", false);
}
}
else
{
} }
private bool hasKey(System.Collections.Specialized.NameValueCollection nv,string pKey)
{
return true;
}
private void Application_EndRequest(Object source, EventArgs e)
{ } public void Dispose()
{
}目的是实现通过调用RunModule来定位页面。我在目的页面中使用了ASP.net AJAX重定向已经可以实现,但是在打开的页面中点击功能时抱错。
当点击一次的按钮的时候一切正常,但是再点击其他按钮的时候就报 404错误,我用web development tools跟踪了一下,发现页面的路径发生了变化定向到了我所打开的文件路径。例如:
第一次点击 请求地址为: localhost/website/components/MK1/MKWH.aspx?ID=111
第二次点击 请求地址变成:localhost/website/FrameWork/MKWH.aspx?ID=111请问有什么方法能不让重定向的时候改变其地址
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货