ASP.NET MVC return empty view
Solution 1:
return instance of EmptyResult class
return new EmptyResult();
Solution 2:
You can return EmptyResult to return an empty view.
public ActionResult Empty()
{
return new EmptyResult();
}
You can also just return null
. ASP.NET will detect the return type null
and will return an EmptyResult for you.
public ActionResult Empty()
{
return null;
}
See MSDN documentation for ActionResult for list of ActionResult types you can return.
Solution 3:
if you want to return nothing you can do something like
if (!returnValue)
return Content("");
return View(RealView);