C# Razor Task<string> async not working -


so unfortunately i'm dealing c# razor web-forms (not mvc) web application.

i given c# program class consisting of async functions need make work on cshtml page , cannot figure out how...

the 2 functions below c# class worked c# forms application. (notice "textbox1" assigned text).

my problem need string variable "xml" displayed on cshtml page (preferably in "textarea" element) , cannot seem call showdata() function retrieve value

can help?

 public static async void showdata(string gid) {     string xml = "";     try     {        xml = await waitasynchronouslyasync(gid);        //the original code set textbox string value        //i need revise code can display on cshtml page        textbox1.text = xml;      }     catch (httprequestexception)     {         throw new applicationexception("could not connect server");     }        }   public static async task<string> waitasynchronouslyasync(string gid) {     await task.delay(10);     urllink = "*** custom intranet url ***";     ....     ....     ** preparing token/client response url **     ....     ....     string result = await serviceclient.getstringasync(urllink);     return result; } 

i've tried bypass void function , access task<string> function, cannot convert task<string> string value.

async void difficult work with begin with, , even more on asp.net.

i've tried bypass void function , access task function

or change async void showdata async task showdata - long avoid async void, you'll same place.

but cannot convert task string value.

you await:

var xml = await waitasynchronouslyasync(gid); 

or:

await showdata(gid); 

your calling function need marked async , return task/task<t>. yes, cause async/await "grow" through code base, , yes, both normal , necessary.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -