title: How to add data from ASP form to MongoDB collection?
body: <p>I'm trying to make a form that asks for a username and password, and adds the values to a MongoDB collection when the user clicks &quot;Submit&quot;. I've figured out how to list all users by calling a Get() method OnGet(), but I'm confused about posting data to the database.</p>
  <p>This is my form:</p>
  <pre><code>                &lt;form method=&quot;post&quot;&gt;
                      &lt;fieldset&gt;
                          &lt;legend&gt;User Creation&lt;/legend&gt;
                          &lt;input type=&quot;text&quot; name=&quot;input_username&quot; value=&quot;Enter a username&quot; /&gt;
                          &lt;br /&gt;
                          &lt;input type=&quot;text&quot; name=&quot;input_password&quot; value=&quot;Enter a password&quot; /&gt;
                          &lt;br /&gt;
                          &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
                      &lt;/fieldset&gt;
                  &lt;/form&gt;
  </code></pre>
  <p>This is my User.cs Model</p>
  <pre><code>using MongoDB.Bson;
  using MongoDB.Bson.Serialization.Attributes;
  
  namespace project.Model {
      public class User {
          [BsonId][BsonRepresentation(BsonType.ObjectId)]
          public string Id { get; set; }
          public int UID {get; set;}
          public string Username {get; set;}
          public string Password { get; set; }
      }
  }
  </code></pre>
  <p>Essentially, I'd like the text in the input fields to be added to the users' database when the submit button is clicked. I'm new so any help is appreciated, and if any more info is needed please let me know!</p>