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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -