marcusstarnes
marcusstarnes

Reputation: 6531

Appending Url Fragments to MVC Routes?

I want to set up a route in my ASP.NET MVC 3 web application, that has a url fragment appended to it, in the same way as some url's on StackOverflow, e.g:

http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732382#1732382

However, I can't see any (clean) way of achieving this at the moment.

Is there an 'out of the box' solution or do I need to build a helper of some description to append a url fragment to the end of a normal route?

Upvotes: 0

Views: 700

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038820

You could use helpers. For example:

@Html.ActionLink(
    "linkText", 
    "action", 
    "controller", 
    null, 
    null, 
    "fragment", 
    new { id = "123" }, 
    new { @class = "test" }
)

or if you want only an url you could use the GenerateUrl method.

Upvotes: 2

Related Questions