相关疑难解决方法(0)

返回new EmptyResult()VS返回NULL

在ASP.NET MVC的时候我的行动将不会返回任何东西我使用return new EmptyResult()return null

有什么不同吗?

asp.net-mvc action asp.net-mvc-3

59
推荐指数
3
解决办法
4万
查看次数

干净的方式返回一个空的mvc局部视图

在cshtml文件中,根据条件,返回空部分视图的最佳方法是什么?

现在我有:

@if(Model.Count() > 0)
{
  loooonng partial view block of markup code
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能重新做到更接近这个看起来更干净:

@if(Model.Count() == 0)
{
  render an empty partial view
}

  loooonng partial view block of markup code goes here   <- This will obviously get executed only if Model.Count() > 0
Run Code Online (Sandbox Code Playgroud)

提前致谢 !

c# asp.net-mvc asp.net-mvc-partialview

17
推荐指数
4
解决办法
2万
查看次数