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 -
1st action method returns regular view. @ client-side, make ajax request action method 2.
2nd action method returns json response
fyi: want make sure 2nd action method requires user login access. otherwise, might encounter ddos attack.
Comments
Post a Comment