C# 是否清除aspnet mvc中重定向的哈希和参数?
考虑控制器中的以下代码:C# 是否清除aspnet mvc中重定向的哈希和参数?,c#,asp.net,asp.net-mvc,redirect,C#,Asp.net,Asp.net Mvc,Redirect,考虑控制器中的以下代码: protected override void OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext) { if (!this.IsAuthorized) { filterContext.Result = RedirectToAction("Index", "Home", new { area = "" });
protected override void OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext)
{
if (!this.IsAuthorized)
{
filterContext.Result = RedirectToAction("Index", "Home", new { area = "" });
//filterContext.Result = Redirect(Url.Content("~/Home/Index")); // Gives same result as the previous row
return;
}
base.OnActionExecuting(filterContext);
}
如果我在未授权时输入以下url:somecontroller/someaction#/?tab=Foo
我被重定向到:
/Home/Index#/?tab=Foo
为什么没有从url中删除哈希?如何在服务器端摆脱它?这是不可能的。命名锚(
#/?tab=Foo
)不是请求的一部分,浏览器不会将命名锚发送到服务器。看看