简体   繁体   English

呼叫页面未加载

[英]call page without loading

I am working in a C# code behind file. 我正在使用文件后面的C#代码。 Basically what is going on is that I am trying to keep the data between two session, one classic asp one .net in parallel. 基本上发生了什么事,我试图将数据保持在两个会话之间,一个经典的asp与一个.net并行。 If the language choice from the .net session is updated I want to call the page update_lang.asp page and pass it the users new language choice. 如果.net会话中的语言选择已更新,我想调用页面update_lang.asp页面并将其传递给用户新的语言选择。 I do not want to pass control to this page, nor do I want to load it, I just simply want it to 'run' and update the necessary session variable, how do I call the page. 我既不想将控制权传递给此页面,也不想加载它,我只是希望它“运行”并更新必要的会话变​​量,我怎么称呼该页面。

My first thought was session.transfer() but this transfers control, I want the current page to continue running, any ideas? 我的第一个想法是session.transfer(),但是这转移了控制权,我希望当前页面继续运行,有什么想法吗?

Thanks 谢谢

You could try using the WebClient (http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx). 您可以尝试使用WebClient(http://msdn.microsoft.com/zh-cn/library/system.net.webclient.aspx)。 It allows you to open any webpage, so you could easily open your ASP file. 它允许您打开任何网页,因此您可以轻松地打开ASP文件。

public void LoadPage()
{
    string DestinationUrl = ".../file.asp";
    WebClient wc = new WebClient();

    string data = "Some data";

    //String s = wc.UploadString(DestinationUrl, data);
    String s = wc.UploadStringAsync(DestinationUrl, data);
}

Small sidenote: Although it may be possible, it sounds like a real hacky solution.. Maybe you could look for a more solid way... 小旁注:尽管有可能,但这听起来像是一个真正的hacky解决方案。也许您会寻找更可靠的方法...

Edit 编辑

As Balexandre points out, it is better to do a Async-call, if you don't need to wait on the result. 正如Balexandre指出的那样,如果您不需要等待结果,最好进行异步调用。 This way, the call won't block the thread. 这样,调用不会阻塞线程。

Make an http web request: 发出http Web请求:

HttpWebRequest myReq =
   (HttpWebRequest)WebRequest.Create("http://www.mypage.com/");
WebResponse myResponse = myReq.GetResponse(); 

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx http://msdn.microsoft.com/zh-CN/library/system.net.httpwebrequest.aspx

You could inject javascript into the page that makes an AJAX call to the configuration page in question. 您可以将javascript注入该页面,以对该问题的配置页面进行AJAX调用。

This would cause the user's machine to make the call if that is preferable. 如果可以的话,这将导致用户的机器拨打电话。

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

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