Good day.

There is a view on which there is ActionLink (). Also in the controller there is a method

public async Task<ActionResult> Delete(string id) { // TODO: Вызвать запрос о подтверждении. var user = await UserManager.FindByIdAsync(id); var res = await UserManager.DeleteAsync(user); return Index(); // Метод можно и переписать } 

Is it possible to somehow call this method from the view by clicking on the \ ActionLink \ Something similar button so that the method is executed, but the transition between the pages is not implemented?

Thank.

  • You can - use jQuery.ajax . "confirmation request" - do it on the client before ajax. What is the meaning of awaits in your code? - Igor
  • one
    @Igor, what's wrong with awaits in this code? What did you mean? In theory, there are asynchronous calls to the database, the thread is released to process the next request. - nikita

1 answer 1

Sure you may. Action Result is an abstract class that has many descendants. http://metanit.com/sharp/mvc/3.4.php - you can look here.

In your case, return the EmptyResult.

  • Thank you for your advice. I tried - get the request threw on an empty page (here you have an EmptyResult). I used return RedirectToAction("Index"); - exactly what is needed. But is it right? (Visually, yes) - bodynar
  • one
    in fact, it is true, it transfers you to the address where you are, accordingly, the update does not occur. - Oleg Skidan