I have controller methods that do stuff with WMI classes (waking selected machine, opening or closing processes, initiating an RDP session) and then reload the current view. To reload I've tried the following:
return View();
return RedirectToAction("Index", "RenderNodesController");
return RedirectToAction("Index");
return Redirect(Request.UrlReferrer.ToString());
The methods all execute successfully with regards to performing the WMI calls, but the return statement doesn't reload the page. If I refresh the page manually it reloads and displays changed information as expected. Also rather weirdly if I step through the return statements in the debugger I see that the view's Index method executes so debugging seems not to help in this instance. I'd be grateful for any help.
Just wanted to add some explanation to this answer:
Because you're performing an AJAX request, it won't reload the user's browser page on success, all it will do is return the results of the action method called within the result parameter. $.post is a shorthand version of $.ajax so the behaviour will be the same.
Solution:
Use for example location.reload(true)
(as you did).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With