使用JS window.open调用正确的Web重定向

时间:2009-10-06 17:05:51

标签: asp.net

在测试服务器上我的网址= HTTP: //scantdev04:8086/ActivityReport.aspx

我想使用查询数据预填充新网址并将其传递给新网址:

string sUrl = sRelativePath +“?Organization =”+ sOrganization                                         +“&& StartDate =”+ sStartDate                                         +“&&& EndDate =”+ endDate;

string displayScript =“”+         “window.open('”+ sUrl +“','DisplayReport',”+         “'width = 1200,height = 800,toolbar = yes,menubar = yes,resizable = yes,scrollbars = yes')”+         “”;

非常直接。

在开发框中,localhost,一切都很好。

但是在测试中,URL吐出如下: http://www.displayreport.aspx/?Organization=Correctional%20Alternatives,%20Inc&&StartDate=09-01-2009&&EndDate=10/6/2009%2012:00:00%20AM

如何修复www。现在就在那里并重复“http://scantdev04:8086/

我宁愿不将其推送到web.config,但如果有必要的话。

2 个答案:

答案 0 :(得分:0)

您的sRelativePath字符串来自哪里?

答案 1 :(得分:0)

发现这一点似乎有效:

旧版本: string sRelativePath = Request.ApplicationPath +“/DisplayReport.aspx”;

现在改为:
string sRelativePath = GetWebAppRoot()+“/ DisplayReport.aspx”;

GetWebRoot(): string host =(HttpContext.Current.Request.Url.IsDefaultPort)?

       HttpContext.Current.Request.Url.Host : HttpContext.Current.Request.Url.Authority;

   host = String.Format("{0}://{1}", HttpContext.Current.Request.Url.Scheme, host);

  if (HttpContext.Current.Request.ApplicationPath == "/")

         return host;

    else

     return host + HttpContext.Current.Request.ApplicationPath;