locked
How to break a page immediately when it is loading and switch to another page RRS feed

  • Question

  • User-147228924 posted

    Hi,

         I have a page which will run a function which takes 3 to 4 minutes. Now, if I want to change to another page, the original page keeps running and take a while to switch to another page. How can I switch to another page quickly and not need to wait for a while of the original page?

    Tuesday, July 10, 2018 6:23 AM

All replies

  • User1100692814 posted

    Hi,

    If I had this issue, I would look at running a background task.

    Checkout:

    https://www.hanselman.com/blog/HowToRunBackgroundTasksInASPNET.aspx

    https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-2.1

    It depends on your .NET Framework version but these links should get you going.

    Thanks

    /D

    Tuesday, July 10, 2018 7:59 AM
  • User-147228924 posted

    But I just want to stop the page loading process where I press a menu click and switch to another <g class="gr_ gr_54 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" id="54" data-gr-id="54">aspx</g>.  Is it going to use background task?

    Tuesday, July 10, 2018 8:09 AM
  • User465171450 posted

    Not at all. This will have nothing to do with ASP.Net. This is completely the browser and how it is handling events. If it's waiting and receiving data, it will wait to receive data. If a click on a link is slow there won't be anything you can do with that. The browser is just busy doing something. 

    Tuesday, July 10, 2018 1:00 PM
  • User1100692814 posted

    It sounds like this is client side related. If the browser is slow and then you want to stop it, this is specific to the user.

    Clicking a link or simply redirecting the user would solve your problem but it won't have finished processing the original request. I think that for some requests from the client, the server does not respond, or the response time is too long. We could limit the request time by setting the web server's timeout. For details, please check the related web server, such as KeepAliveTimeout, client_header_timeout, send_timeout attributes. Check https://msdn.microsoft.com/en-us/library/e1f13641(v=VS.100).aspx 

    Thanks

    D

    Tuesday, July 10, 2018 2:24 PM
  • User-330142929 posted

    Hi Hon123456.

    In my opinion, I think that for some requests from the client, the server does not respond, or the response time is too long. We could limit the request time by setting the web server's timeout. For details, please check the related web server, such as KeepAliveTimeout, client_header_timeout, send_timeout attributes, etc.

    Best Regards

    Abraham.

    Wednesday, July 11, 2018 7:07 AM
  • User-147228924 posted

    Seems the first request is busy at <g class="gr_ gr_63 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" id="63" data-gr-id="63">running</g> function that makes the switch to other pages slowly. Is that making the function in the first request to background process will make it better?

    Thursday, July 12, 2018 8:43 AM
  • User-330142929 posted

    Hi Hon123456,

    According to your description, I think your idea is constructive. If we implement the previous request via ajax, or it can be handled asynchronously by the background task. I suggest you do this. In addition, I think it is feasible to control request time through the web server.

    Feel free to let me know if you have any question.

    Best Regards

    Abraham

    Monday, July 16, 2018 1:49 AM