简体   繁体   English

关闭代码后面的浏览器--aspx

[英]close Browser from code behind - aspx

I have this aspx page and it works all fine. 我有这个aspx页面,它工作得很好。

protected void Page_Load(object sender, EventArgs e)
{
   string clientID = Request.QueryString["ID"];
   string clientName = Request.QueryString["NAME"];
   folderSearch(clientID, clientName);
}
public void folderSearch(string clientID, string clientName)
{
    SYS.getInfo(searchDBInfo => 
   {
        string folderPath = searchDBInfo.sPath + "\\" + clientID + " - " + clientName;
        if (Directory.Exists(folderPath))
        {
            Process.Start(folderPath);
        }
        else
        {
           Directory.CreateDirectory(folderPath);
           Process.Start(folderPath);
        }
   });
}

I would like the aspx running browser window to be closed straight after it displayed. 我希望运行浏览器窗口的aspx在显示后直接关闭。 means user should not be able to see any browser running but it can still do its job in background. 意味着用户不应该看到任何浏览器在运行,但它仍然可以在后台运行。

Please help me guys! 请帮帮我们! Thanks. 谢谢。

I would like the aspx running browser window to be closed straight after it displayed. 我希望运行浏览器窗口的aspx在显示后直接关闭。 means user should not be able to see any browser running but it can still do its job in background. 意味着用户不应该看到任何浏览器在运行,但它仍然可以在后台运行。

It is not in your control, it is a browser function, and you can't do anything about it. 它不在你的控制之下,它是一个浏览器功能,你无法做任何事情。

The only solution to do this is by Javascript (client side) with window.close() and you'll have a prompt showing you "Do you want to close this window" . 执行此操作的唯一解决方案是使用带有window.close()的Javascript(客户端),并且您将显示“您是否要关闭此窗口”的提示。

One solution would be to "close" after display is to redirect after a sleep and you'll not have the prompt. 一个解决方案是在显示后“关闭”以在睡眠后重定向并且您将没有提示。

Note : The page won't show up if your server-side code is not finished. 注意:如果服务器端代码未完成,则不会显示该页面。

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

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