RedirectToAction() with tab-id
I have a web application in ASP.NET MVC and in there i have a jqueryUI tab with forms in. And when i submit i want to return to the open开发者_运维知识库 tab.
With me RedirectToAction() i create the url
www.foo.com/CV/edit/9
But i want to be able to generate
www.foo.com/CV/edit/9#tab-2
I tried with RedirectToAction("edit/"+id+"#tab-2"), but that generates:
www.foo.com/CV/edit/9%23tab-2
any1 knows the answer?
Create the URL, then append #tab-2
to it. Return a RedirectResult to redirect to the created URL:
return new RedirectResult(Url.Action("edit", new { id }) + "#tab-2");
You can't redirect to a hashed URL because they aren't a physical URL. The hash is used for internal page anchoring. You'd be best off using a URL parameter like &tab=2
精彩评论