Submitting a form in ASP.NET Core [WIP]

Posted on February 10, 2023

Right so I've been ill this week but I wanted to start the first of a series of MVP snippets - i.e. the least code necessary to do something.

In this instance I was weirdly frustrated with a simple tutorial on how to submit a form and change the page based on that response.

I'll be building these up over time but wanted to get it started!

Level 1: Form submits a GET request, page shows form input 

Here's the smallest razor snippet I could make for making, submitting and viewing a form in a razor page.

<form method="get">
    <div>
        <input type="text" name="inputValue" value="" />
        <input type="Submit" value="Submit" /><br/>
    </div>
</form>

<h1>@Request.Query["inputValue"]</h1>

...and that's it for right now - that will change shortly though!

Any feedback - @jacksorjacksor or email me at jacksorjacksor dot pm.me

Ciao!

Rich