Tag: 请求

DownloadStringAsync等待请求完成

我使用此代码来检索url内容: private ArrayList request(string query) { ArrayList parsed_output = new ArrayList(); string url = string.Format( “http://url.com/?query={0}”, Uri.EscapeDataString(query)); Uri uri = new Uri(url); using (WebClient client = new WebClient()) { client.DownloadStringAsync(uri); } // how to wait for DownloadStringAsync to finish and return ArrayList } 我想使用DownloadStringAsync因为DownloadString挂起了应用程序GUI,但我希望能够根据request返回结果。 我怎么能等到DownloadStringAsync完成请求?

获取用户在浏览器中输入的确切URL

我想获得用户输入浏览器的确切url。 当然我总是可以使用像Request.Url.ToString()这样的东西但是在下列情况下这不能给我我想要的东西: http://www.mysite.com/rss 使用上面的URL, Request.Url.ToString()会给我的是: http://www.mysite.com/rss/Default.aspx 有谁知道怎么做到这一点? 我已经尝试过了: Request.Url Request.RawUrl this.Request.ServerVariables[“CACHE_URL”] this.Request.ServerVariables[“HTTP_URL”] ((HttpWorkerRequest)((IServiceProvider)HttpContext.Current).GetService(typeof(HttpWorkerRequest))).GetServerVariable( “CACHE_URL”) ((HttpWorkerRequest)((IServiceProvider)HttpContext.Current).GetService(typeof(HttpWorkerRequest))).GetServerVariable( “HTTP_URL”)