Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 是否清除aspnet mvc中重定向的哈希和参数?_C#_Asp.net_Asp.net Mvc_Redirect - Fatal编程技术网

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
)不是请求的一部分,浏览器不会将命名锚发送到服务器。看看