-1

I use location.hash javascript mathod a lot at my ajax requests. Generally I replace standard {action}/{id} with {action}#{id}

How can I introduce this strategy at rounting system? I wol like write:

 @Html.ActionLink(text, action, controller, new { id }, new { })

and this generates /controller/action#id ?

Oh may be it's not good idea? How do you process ajax requests(open some entity at list?)

Thanks

0

3 Answers 3

3

The answer you seek is here:

How to access AJAX hash values in ASP.NET MVC?

TL;DR - Its impossible.

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

Comments

1

Remember: Routing isn't just for generating links; it's also for parsing incoming URIs. Incoming URIs don't have hash/fragments on them, so the route you propose, if it were possible, wouldn't work for incoming requests.

You can write your own HTML helper, in lieu of Html.ActionLink to create the URI with the hash, if you want, but it can't be a route.

Comments

0

this should work as you want.

RedirectResult(Url.Action("{action}") + "#{id}");

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.