passing section id in mvc using @Url.Action so tha

2019-06-22 08:03发布

问题:

I am a web designer but I am told to design static pages in mvc where rather then using href="some url" I have to use href="@Url.Action("Controller", View)" Now I want to pass a section id in the url so when the user redirects it will be scrolled down to that specific section usually in html this is the syntax I use

href="index.html#mysectionid"

in Html I have something Like this

<section id="mysection">

</section>

I want to Know How I am gonna do this thing in mvc. Thanks

回答1:

You can mix C# code with normal html in Razor:

<a href="@Url.Action("Contact", "Home")#mysection">Test</a>