那么,在教程中,他们并没有真正“保存在内存”之间的请求。在每个请求中,该值都传递给action方法,然后将其传递给视图,并在该方法中用于创建分页和排序链接。
以前,寻呼,而不是单独地将每个参数时,我只是有读取查询字符串和使用每个提供参数建立的链路的方法:
NameValueCollection queryString = helper.ViewContext.HttpContext.Request.QueryString;
foreach (string key in queryString)
{
if (key != null)
{
if (!newValues.ContainsKey(key))
{
if (!string.IsNullOrEmpty(queryString[key]))
{
newValues[key] = queryString[key];
}
}
}
}
然后,创建链接,我使用:
string link;
if (!string.IsNullOrEmpty(routeName))
{
link = helper.RouteLink(text, routeName, newValues).ToString();
}
else
{
actionName = actionName ?? values["action"].ToString();
controllerName = controllerName ?? values["controller"].ToString();
link = helper.ActionLink(text, actionName, controllerName, newValues, null).ToString();
}
return string.Concat(" ", link);