如果在我的控制器中:
public ActionResult Index()
{
//no code implied
return View;
}
然后在返回的视图中:
<%if(ViewData["SomeString"].ToString() != "True") {%> show this <%}%>
由于对象引用没有对象,我会在运行时出错。
但是在我做的页面内部:
<%if(Request.QueryString["Something"].ToString() != "True") {%> show this <%}%>
更新:我确实得到了错误。
编辑:看起来他们的行为毕竟是一样的。