c# - Asp.NET return ActionResult while adding data to user session -


i have method similar one:

 public actionresult index()   {         session["test"] = getdata();     return view();   } 

because getdata() method takes long, wondering if can async in order return view while getdata() running , adding object user session. thought @ splitting method 2 methods first return 'view()' , second 1 called ajax , adding object session, want use last resort.

thanks in advance!

because getdata() method takes long, wondering if can async in order return view while getdata() running , adding object user session.

you not want run long running query on initial page load. user might think network connection lost, , keeps pressing f5 refresh page.

instead, want 2 action methods -

  1. 1st action method returns regular view. @ client-side, make ajax request action method 2.

  2. 2nd action method returns json response

fyi: want make sure 2nd action method requires user login access. otherwise, might encounter ddos attack.


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -