html button link in ASP.NET MVC

I have a mvc application using C# and razor syntax.

So on one of my views I have the following razor link. If I click on this link I'm taken to the Index.cshtml view which is in the Home folder inside the Views folder. So that link works correctly.

@********* link display text - View (name of cshtml file) - name of folder inside the Views folder *********@
@Html.ActionLink("GoToIndexPage", "Index", "Home")

Is it possible to instead of having a razor link on this page, to instead have a regular html button like  this.
When I click on this button link I want it to go to the same Index.cshtml  page as the razor link above.

I tried something like this but doesn't work.
Is this possible? if so anyone know the correct syntax?

<input id="BtnTest1" type="button" value="Back" class="ButtonStyle" onclick="window.location.href = 'index.cshtml'" />
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lokesh B RDeveloperCommented:

You can use Url.Action for doing this on html button

Home - Controller Name
Index - Action Name

<input id="BtnTest1" type="button" value="Back" class="ButtonStyle" 
onclick="window.location.href='<%= Url.Action("Index", "Home") %>';" />

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
In mvc, you cannot access the view page directly. There is a web.config file in the views folder which has settings restricting direct access to the view.

You either do this

<input id="BtnTest1" type="button" value="Back" class="ButtonStyle" onclick="window.location.href = '/Home/Index'" />

correct approach


You should remove the web.config which is a security issue as any one could access your view directly. Not a good idea.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.