RedirectToAction () with tab id

I have a web application in ASP.NET MVC, and there I have a jqueryUI tab with forms. And when I submit, I want to return to the open tab.

With me RedirectToAction () I create a 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 this generates:

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

does any1 know the answer?

+7
source share
2 answers

Create a url, then add #tab-2 to it. Return RedirectResult to redirect to the generated URL:

 return new RedirectResult(Url.Action("edit", new { id }) + "#tab-2"); 
+20
source

You cannot redirect a hashed url because it is not a physical url. A hash is used to internally anchor pages. It’s best to use a URL parameter like &tab=2

-one
source

All Articles