Search code examples
c#htmlasp.net.net-core

How do I navigate to a new page with a Button in ASP.net Core?


I've got a webpage that currently links to another page like this:

<a asp-action="Create">Create New</a>

I've tried this and it just sat on the page very happily, but didn't take me where I want to go:

<button asp-action="Create" class="btn btn-primary">Create</button>

How can I change this to use a button instead of a text link?


Solution

  • This should work:

    <a asp-action="Create"><button class="btn btn-primary">Create</button></a>