简体   繁体   English

更新面板+ window.open + https

[英]Update Panel + window.open + https

I'am developing with c# and asp.net. 我正在使用c#和asp.net进行开发。

I have some pages with update panels. 我有一些带有更新面板的页面。 In this update panels there is a button that redirects to a new window. 在此更新面板中,有一个按钮可重定向到新窗口。 This is done by calling the window.open with the scriptmanager in code behind. 这是通过在后面的代码中使用scriptmanager调用window.open来完成的。 Everything works fine until I don't use https. 一切正常,直到我不使用https。 If I use tunnelling with a router to have a secure line till the router and then use a proxy to access my webpages, the window.open called from the buttons that are in an update panel open a new register card, but there I get the error : page not found. 如果我通过路由器使用隧道来建立一条安全线路,直到路由器,然后使用代理来访问我的网页,则从更新面板中的按钮调用的window.open会打开一个新的注册卡,但在那里错误:找不到页面。 In the url I can see that the router did not put the proxy+IP before the path. 在url中,我可以看到路由器没有将proxy + IP放在路径之前。 That does not happen if I remove the update panel.With Firebug I could see that with the update panel I get a POST and in the resonse the contentType is text/plain. 如果我删除更新面板,则不会发生这种情况。使用Firebug,我可以看到在更新面板中我收到了POST,并在共振中,contentType为text / plain。 Without the update panel there is a GET and the response contentType is text/html. 没有更新面板,则有一个GET,响应contentType是text / html。 So what can I do to run this without removing the update panels? 那么,如何在不删除更新面板的情况下运行它呢?

This works fine until I don't use https over my proxy: 直到我不在代理上使用https之前,它都可以正常工作:

protected void btnPrint_Click(object sender, EventArgs e)
{
     url = "~/Gui/Report/ReportViewer.aspx?ReportName=CustomerReport";
     Page page = (Page)HttpContext.Current.Handler;

     if (page == null) {
         Redirect(url);
     }

     url = page.ResolveUrl(url);

     string script = @"window.open(""{0}"");";

     script = String.Format(script, url);
     ScriptManager.RegisterStartupScript(page,
         typeof(Page),
         "Redirect",
         script,
         true);
}

<asp:UpdatePanel ID="UpdatePanel" runat="server">
    <ContentTemplate>
         <dx:ASPxButton runat="server" ID="btnPrint"
               Text="print" OnClick="btnPrint_Click">
         </dx:ASPxButton>
    </ContentTemplate>
</asp:UpdatePanel>

Got it.... 得到它了....

the information that the scriptlanguage is javascript is lost if I am using the proxy (strange...?!?!). 如果我使用代理服务器(奇怪的...?!?!),则脚本语言为javascript的信息会丢失。 If I build the script tags on my own with adding the attribut "language='javascript'" then everything works fine. 如果我通过添加属性“ language ='javascript'”自行构建脚本标签,则一切正常。 Can anybody tell me why this information is lost? 谁能告诉我为什么这些信息会丢失?

Here the new code: 这里是新代码:

protected void btnPrint_Click(object sender, EventArgs e)
{
 url = "~/Gui/Report/ReportViewer.aspx?ReportName=CustomerReport";
 Page page = (Page)HttpContext.Current.Handler;

 url = page.ResolveUrl(url);

 string script = "window.open('" + url + "');";

 System.Text.StringBuilder sb = new System.Text.StringBuilder();
 sb.Append("<script language='javascript'>");
 sb.Append(script);
 sb.Append("</script>");

 ScriptManager.RegisterStartupScript(page,
     typeof(Page),
     "Redirect",
     script,
     false);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM