我可以在ASP.NET MVC中结束视图的呈现吗 [英] Can I end the rendering of a view in asp.net mvc

查看:63
本文介绍了我可以在ASP.NET MVC中结束视图的呈现吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我试图找出一种方法,如果我的模型为null,则该方法可以呈现错误消息,并且在该错误消息之后,视图应停止呈现,这可能吗?我首先想到的是response.end()方法,但是主视图无法完成渲染.这是我们自己需要构建的框架的一部分吗?

So I am trying to figure out a method that can render a error message if my model is null and after that error message the view should stop rendering, is this possible? My first thought was the response.end() method but then the master view won't finish rendering. Is this somthing thats part of the framework our do need to build it myself??

推荐答案

此逻辑应真正存在于控制器中,该控制器将根据模型的存在或不存在选择呈现正确的视图.

This logic should really sit in a controller which would choose to render the correct view based on the presence or absence of the model.

这使ASP MVC管道保持完整,并消除了对视图快捷方式的需求.

This keeps the ASP MVC pipeline in-tact and eliminates the need for view shortcuts.

这篇关于我可以在ASP.NET MVC中结束视图的呈现吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆