带tab-id的RedirectToAction()

问题描述:

我在ASP.NET MVC中有一个Web应用程序,并且在其中有一个带有表单的jqueryUI选项卡. 当我提交时,我想返回到打开选项卡.

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.

和我一起RedirectToAction()创建网址

With me RedirectToAction() i create the url

www.foo.com/CV/edit/9

但是我希望能够生成

www.foo.com/CV/edit/9#tab-2

我尝试使用RedirectToAction("edit/" + id +#tab-2"),但是会生成:

I tried with RedirectToAction("edit/"+id+"#tab-2"), but that generates:

www.foo.com/CV/edit/9%23tab-2

any1知道答案吗?

any1 knows the answer?

创建URL,然后将#tab-2附加到URL.返回一个RedirectResult以重定向到创建的URL:

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