我有一个过滤器属性,用于检查路由参数,如果它没有退出,我会应用一些逻辑来检查当前请求是否需要重定向到另一个路由。
我的代码看起来像这样
Public Overrides Sub OnActionExecuting(filterContext As ActionExecutingContext)
If Not filterContext.RouteData.Values.ContainsKey("SearchKey") Then
strSearchKey = strFrom.ToString.Substring(strFrom.ToString.IndexOf("/") + 1)
strFrom = strFrom.ToString.Substring(0, strFrom.ToString.IndexOf("/") + 1)
If Not IsNullOrEmpty(strSearchKey) Then
Dim values As New Web.Routing.RouteValueDictionary
values.Add("SearchKey", strSearchKey)
values.Add("From", strFrom)
values.Add("controller", "SearchResults")
values.Add("action", "Category")
filterContext.Result = New RedirectToRouteResult("SearchCategory", values)
'filterContext.Result.ExecuteResult(filterContext)
End If
End If
End Sub
我正在做的是让它重定向,但问题是它会导致一个无限循环,我无法找到它为什么只是继续击中同一条路线的原因。 #39;从反复重定向。