S
S
slaum2015-02-11 19:35:32
ASP.NET
slaum, 2015-02-11 19:35:32

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");

Judging by the breakpoints, the problem occurs after GetJsonString is executed.
The code is like this:
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>());
        }

Explain why I'm stupid

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vitaly Pukhov, 2015-02-12
@Neuroware

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

M
MIsternik, 2015-04-26
@MIsternik

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;

V
Vyacheslav, 2017-10-05
@sazhyk

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

N
Nikita Ermilichev, 2017-10-05
@Masas

# around here return

Well, something is coming back.
Please provide the entire function code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question