title: NET 6 Core using Pages posting to a custom method
body: <p>Using the NET 6 core application with <strong>Pages</strong>.</p>
  <p>Right out of the box the project has the following &quot;code behind&quot;</p>
  <pre><code>public class IndexModel : PageModel
  {
      private readonly ILogger&lt;IndexModel&gt; _logger;
  
      public IndexModel(ILogger&lt;IndexModel&gt; logger)
      {
          _logger = logger;
      }
  
      public void OnGet()
      {
  
      }
  
      // This is this the new code 
      public void MyCustomMethod()
      {
          var debug = &quot;Stop Here debug break point&quot;;
      }
  }
  </code></pre>
  <p>The front end has the following:</p>
  <pre><code>@page
  @model IndexModel
  @{
     ViewData[&quot;Title&quot;] = &quot;Home page&quot;;
  }
  
  &lt;div class=&quot;text-center&quot;&gt;
     &lt;form action=&quot;MyCustomMethod&quot; method=&quot;get&quot;&gt;
         &lt;input type=&quot;submit&quot; /&gt;
     &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Unable to <strong>GET</strong> or <strong>POST</strong> to the custom method (MyCustomMethod) in the <strong>NET 6 CORE using PAGES</strong>.</p>
  <p>It could be a dumb question by I tried to google for the past 2 hours and can not find anything related to what I am doing. Please help.</p>
  <p>Trying to use a simple form to get or post to the &quot;code behind&quot;. When page load I do see a debug going into OnGet() method which it should do but clicking on a button in a form it never makes it into MyCustomMethod().</p>
  <p>Thank you.</p>
  <p>Did the following change to a code:</p>
  <pre><code>    [HttpPost] // Second run added this because it was still not working
      public void OnPostMyCustomMethod()
      {
          var debug = &quot;Stop Here debug break point&quot;;
      }
  
  Front page
      &lt;form action=&quot;MyCustomMethod&quot; method=&quot;post&quot;&gt;
      &lt;input type=&quot;submit&quot; /&gt;
  &lt;/form&gt;
  </code></pre>
  <p>Still unable access:</p>
  <p><a href="https://i.stack.imgur.com/rYUcP.png" rel="nofollow noreferrer">Debug Run</a></p>