ASP.NETMVCプログラミングは初めてです。私のサイトには、現在のページの終わりに応じて、署名されていないすべてのユーザーをフォルダー\content\にあるページにリダイレクトする次のコードがあります。ユーザーがすでにこのページにリダイレクトされている場合にリダイレクトを行わないようにするには、このコードを変更するにはどうすればよいですか?
using System.Globalization;
using System.Web;
using System.Web.Mvc;
namespace MYSITE.Web.Infrastructure
{
public class CategoryRedirectAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
if (!HttpContext.Current.User.Identity.IsAuthenticated)
{
if (((ViewResult)filterContext.Result).ViewName.StartsWith("ProductList", true, CultureInfo.InvariantCulture))
{
var categoryProductPath = filterContext.RouteData.Values["categoryProductPath"].ToString().Split('/');
if (categoryProductPath.Length > 0)
{
HttpContext.Current.Response.Redirect("/Content/" + categoryProductPath[categoryProductPath.Length - 1]);
}
}
}
}
}
}