I want to use a RedirectToRouteResult to redirect to a url like /users/4#Summary. Using ASP.NET MVC 1.0, I haven't been able to find a way to do that - have I missed it?
I do a something like that on my site here. But it's not with RedirectToRouteResult
. RedirectToRouteResult
does not support including an anchor part to the url.
You need to build the link yourself and perhaps even the logic to handle the processing of the anchor part - as i did. My application tries to replicate functionality similar to that of the Facebook photo gallery views. Each link to a different page must have a unique url, so for this i use the anchor part. But coz it does not translate direct to a route i have to parse the anchor part of the url manually on the page and use ajax to load in the appropriate content. This is what i wanted so it works for me.
Download the source code of MVC and check out how RedirectToRouteResult works
There may be better ways but a simple inheritance of RedirectToRouteResult and an override of ExecuteResult to allow an optional anchor part should fix the problem
You should properly build your routes in route table. Eg.:
routes.MapRoute("MyRoute" ,"{controler}/{id}#{detail}" ,new { controller = "users", action = "index", id = (string)null, detail = "Summary" });
I had a similar problem, take a look here:
I ended up creating a route using #.