3

Consider the following code within 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?

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.