Answer the question
In order to leave comments, you need to log in
Why does a web app go into infinite loading?
I'm just starting to learn Asp.net MVC and it's still a complete oak.
The bottom line is, there is a web application: on the page, an input field for text and a Submit button.
When the button is clicked, a post request occurs. As a result, the browser shows the download indefinitely and nothing happens. The controller does the following:
OuterTrackAction outer = new OuterTrackAction();
var t = outer.GetJsonString(track.TrackString);
track.TrackJson = t.Result;
return Redirect("/TrackCheck/TrackCheck/@track");
async public Task<string> GetJsonString(string no_)
{
no_ = ApiUrl + no_;
var client = new HttpClient();
var headers = client.DefaultRequestHeaders;
headers.UserAgent.ParseAdd("ie");
headers.UserAgent.ParseAdd("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
var response = await client.GetAsync(new Uri(no_));
return(await response.Content.ReadAsAsync<string>());
}
Answer the question
In order to leave comments, you need to log in
to begin with, you can wrap the code in a try and see if there is an error that you can write to the log
I can be wrong, but it's possible that the main thread is blocked on t.Result and cannot receive a signal from the thread performing the asynchronous operation.
Try replacing
var t = outer.GetJsonString(track.TrackString);
track.TrackJson = t.Result;
to var t = Task.Run(()=>outer.GetJsonString(track.TrackString)).Result;
return terminates the execution of the function, but print does not. Therefore, you must first, instead of return, add all the necessary values \u200b\u200bin an array, and then return the array itself.
Something like that:
def my_list(path):
filePaths = []
for dirname, dirnames, filenames in os.walk(path):
filenames = filter(lambda x: x.endswith('.html'), filenames)
for filename in filenames:
file = os.path.join(dirname, filename)
filePaths.append(file)
return filePaths
# around here return
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question