W Y A T T F L E M I N G

Truth through experimentation

Razor Pages

ASP.NET Core/MVC: Adding a Button to a Razor View Page that Returns a Method On-Click

I needed to add a button in my ASP.NET Core MVC web application that on-click would start a method that would return a list of items scraped from another website.

Something like this:

The code I got to work for doing so is:


<button type="button" id="startButton" 
    onclick="location.href='@Url.Action('List', 'ArbitrageScraper')'">
    Start  Scrape
</button>

This code resides inside of the View for your controller. My button …

Read More…

My name is Wyatt Fleming. I am a Project Manager at WebJaguar and a life-long learner interested in history, economics, gardening, and computers.