RedirectToAction() with tab-id

本小妞迷上赌 提交于 2019-12-04 21:24:15

问题


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?


回答1:


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");



回答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



来源:https://stackoverflow.com/questions/7725474/redirecttoaction-with-tab-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!