Consider the following code with开发者_JS百科in a controller:
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);
}
If I enter the follwing url when not authorized:
somecontroller/someaction#/?tab=Foo
I get redirected to:
/Home/Index#/?tab=Foo
How come the hash isn't stripped from the url?
How can I get rid of it serverside?This is not possible. The named anchor (#/?tab=Foo
) is not part of the request, the browser does not send the named anchor to the server. Take a look at named anchors are not sent to the web server
精彩评论