I’m using MvcContrib’s strongly typed RedirectToAction() to redirect from one controller action to another, while avoiding magic strings in my application flow, like so:
this.RedirectToAction<FooController>(c => c.Bar());
which in turn redirects to
/foo/bar/
… but now I’d like to be able to redirect to an URL with an anchor/hashtag at the end, and scroll the window to the <a name="yarrr" /> tag, like so:
/foo/bar/#yarrr
I could put the hashtag in TempData[], write it in a javascript variable and have the window scroll via javascript – but I’d rather follow convention and have the hashtag as the end of my URL.
Any ideas or home made solutions for this?
MvcContrib doesn’t seem to support it.
I am not aware of the existence of such an ActionLink overload in MvcContrib but writing one would be trivial:
and then in your view:
UPDATE:
Apparently I misunderstood your question as you were looking for a
RedirectToActionmethod in the controller, not inside the view. My answer is the same as previously:I am not aware of the existence of such an RedirectToAction overload in MvcContrib but writing one would be trivial:and then inside your controller: