今天在看代码时解决了两个小问题,特在这里记录一下,以便以后查询.
故障一: 在MVC中浏览程序时遇到异常:"Session state has created a session id, but cannot save it because the response was already flushed by the application."
解决方法: 在Global类中添加如下代码:
代码
protected void Session_Start(object sender, EventArgs e)
{
var sessionId = Session.SessionID;
if(string.IsNullOrEmpty(sessionId))
{
throw new Exception( " session Id is null or empty.");
}
}
故障二:编译代码时下列代码报错:
<%=Html.ActionLink<GroupController>(g => g.New(), "create group")%>
解决方法:添加对Asp.Net Mvc Feature的引用(右击项目,添加对Microsoft.Web.Mvc程序集的引用)。