Including hash values in ASP.NET MVC URL routes

后端 未结 4 1202
[愿得一人]
[愿得一人] 2020-12-01 09:08

I need to implement hash value i.e the Url should look like this:

/home/index/#create

For this have added a route:



        
相关标签:
4条回答
  • 2020-12-01 09:22

    You cannot fetch the value after the # symbol on the server simply because this value is never sent to the server. Only client side javascript has access to this so defining routes with hash doesn't make much sense.

    0 讨论(0)
  • 2020-12-01 09:26

    As stated there is no way to do this using routing. The only possible solution is to append the # fragment to your url when redirecting in the actions of your controller. Eg.

    return Redirect(Url.Action("Index", "Home") + "#create");
    
    0 讨论(0)
  • 2020-12-01 09:34

    When a browser makes a request for a URL, it does not send anything after a hash to the server. This route may enable you to generate route URLs containing the hash value but there is no way to do anything server-side when the user navigates to such a URL. That's just the way the web works...

    0 讨论(0)
  • 2020-12-01 09:36

    OAuth 2.0 Implicit Flow

    If this has to do with OAuth 2.0 Implicit Flow, you should use Authorization Code Grant instead.

    0 讨论(0)
提交回复
热议问题