title: ASP.NET Core Pass form values on get
body: <p>Here is my cs page:</p>
  
  <pre><code>using System;
  using Microsoft.AspNetCore.Mvc;
  using Microsoft.AspNetCore.Mvc.RazorPages;
  
  namespace CoreRazor2.Pages
  {
    public class IndexModel : PageModel
    {
      [BindProperty]
      public int result { get; set; }
      public void OnGet()
      {
        if (Request.Form["+"] == true)
        {
            result = Int32.Parse(Request.Form["first"]) + Int32.Parse(Request.Form["second"]);
        }
        else if (Request.Form["-"] == true)
        {
          // code for function 2
        }
        else if (Request.Form["*"] == true)
        {
  
        }
        else if (Request.Form["/"] == true)
        {
  
        }
      }
    }
  }
  </code></pre>
  
  <p>and my cshtml page:</p>
  
  <pre><code>@page
  @model IndexModel
  @{
      ViewData["Title"] = "Calculator";
  }
  
  &lt;form method="GET"&gt;
  &lt;label&gt;First Value: &lt;/label&gt;
  &lt;input name="first"/&gt;
  &lt;br/&gt;
  &lt;br/&gt;
  &lt;label&gt;Second Value: &lt;/label&gt;
  &lt;input name="second"/&gt;
  &lt;br/&gt;
  &lt;br/&gt;
  &lt;input type="submit" name="+" value="+"/&gt;
  &lt;input type="submit" name="-" value="-"/&gt;
  &lt;input type="submit" name="*" value="*"/&gt;
  &lt;input type="submit" name="/" value="/"/&gt;
  &lt;/form&gt;
  @Model.result
  </code></pre>
  
  <p>I am trying to figure out which submit gets clicked and then perform different actions depending on the button clicked. How can you do this via a get request. The code gives me an error - 'InvalidOperationException' on the first Request.Form['+'] check. How to do this properly?</p>