【问题标题】:Proper web redirection with JS window.open call使用 JS window.open 调用进行正确的 Web 重定向
【发布时间】:2009-10-06 17:05:51
【问题描述】:

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

我想用查询数据预填充一个新的 URL 并将其传递给新的 url:

字符串 sUrl = sRelativePath + "?Organization=" + sOrganization + "&&StartDate=" + sStartDate + "&&EndDate=" + endDate;

字符串 displayScript = "" + "window.open('" + sUrl + "', 'DisplayReport', " + "'width=1200, height=800, toolbar=yes, menubar=yes, resizable=yes, scrollbars=yes')" + "";

非常直接。

在开发盒,本地主机上,一切都很好。

但在测试中,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,但如果有必要的话。

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    您的sRelativePath 字符串来自哪里?

    【讨论】:

      【解决方案2】:

      找到这个,它似乎工作:

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

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

      GetWebRoot(): 字符串主机 = (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;
      

      【讨论】:

        猜你喜欢
        • 2015-09-16
        • 1970-01-01
        • 2018-01-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-05
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多