HOW? Controller return nothing/current view

管炳
2023-12-01

http://stackoverflow.com/questions/579390/how-controller-return-nothing-current-view

You can return an EmptyResult if you want it to do nothing...

return new EmptyResult();

If you're using the AjaxHelper you can avoid the update by supplying an unsuccessful status code (e.g. 404 or whatever is most appropriate), that'll stop it replacing your div as the javascript in MicrosoftMvcAjax.js explicitly checks for a successful response before updating any elements:-

this.ControllerContext.HttpContext.Response.StatusCode = 404;
return new EmptyResult();

Ultimately the best way to avoid it is to design the partial view so it avoids the problem in the first place (like you mention yourself).


 类似资料: