1Ma*_*yur 2 .net c# asynchronous webclient class-library
它是一个类库,它被称为网页
try
{
System.Net.WebClient wc = WebAccess.GetWebClient();
wc.UploadStringCompleted += new System.Net.UploadStringCompletedEventHandler(wc_UploadStringCompleted);
wc.UploadStringAsync(new Uri("http://" + MobileWLCUrl + urlCreateCacheAPI), GetJSONforGetMenuDetails(Id, MenuIds));
}
catch (Exception ex) { EngineException.HandleException(ex); }
void wc_UploadStringCompleted(object sender, System.Net.UploadStringCompletedEventArgs e)
{
string result = e.Result;
EngineException.CreateLog("Cache Created (for Menus: " + MenuIds + ") in API for LocationId: " + LocId);
}
Run Code Online (Sandbox Code Playgroud)
嗨伙计们,我试图异步地打这个网址而且它给了我这个错误,任何帮助都会受到关注.
Asynchronous operations are not allowed in this context.
Page starting an asynchronous operation has to have the Async attribute set to true
and an asynchronous operation can only be started on a page prior to PreRenderComplete event.
at System.Web.AspNetSynchronizationContext.OperationStarted()
at System.Net.WebClient.UploadStringAsync(Uri address, String method, String data, Object userToken)
at System.Net.WebClient.UploadStringAsync(Uri address, String data)
Run Code Online (Sandbox Code Playgroud)
日Thnx ...
Rom*_*ain 10
将Async="true"参数添加到@Page指令.
<%@ Page Async="true" ... %>
Run Code Online (Sandbox Code Playgroud)
西瓦尼,
您需要"http://" + MobileWLCUrl + urlCreateCacheAPI在以下代码中调用的页面(存储在)中应用此更改:
wc.UploadStringAsync(new Uri("http://" + MobileWLCUrl + urlCreateCacheAPI), GetJSONforGetMenuDetails(Id, MenuIds));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10698 次 |
| 最近记录: |