我正在处理ASP.NET MVC 4
申请。我创建了自定义过滤器,目的是调用显示加载器图像的页面。过滤器如下所示:
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var useLoader = filterContext.RouteData.Values["ul"] as string;
if (string.IsNullOrWhiteSpace(useLoader))
{
var view = new ViewResult()
{
ViewName = "DisplayLoader"
};
view.ViewData.Model = filterContext.HttpContext.Request.Url.PathAndQuery;
view.TempData["ul"] = "1";
filterContext.Result = view;
}
}
在DisplayLoader
视图中,我只是这样做:
@model string
<script type="text/javascript">window.location = '@Html.Raw(Model)';</script>
但问题是重定向后,useLoader
值始终为null
。有没有办法坚持这些数据?