HOW? Controller return nothing/current view

来源:互联网 发布:paxos算法 活锁 编辑:程序博客网 时间:2024/06/01 07:41

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).


0 0
原创粉丝点击