title: unable to write to mongodb from visual studio
body: <p>I just started coding, I decided to build a web app with visual studio and mongodb.</p>
  
  <p>I installed the mongodb driver from visual studio and locally installed mongodb in the default mongodb location. I created the first initial page to create the first user and created a class for mongodb collection, however, every time I submit the information of the user nothing happens, no error messages that I can see, it seems as if everything resolves fine, but when I go to the DB, the collection and first doc. that were supposed to be created are not there, not sure what I'm doing wrong.</p>
  
  <p>this is the frontend code:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CreateUser.aspx.cs" Inherits="Project1.Pages.CreateUser" %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
  &lt;link rel="stylesheet" href="../CSS/common.css" /&gt;
  &lt;title&gt;Create User&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          &lt;img src="../Images/JotNotes.png" /&gt;
          &lt;p&gt;NEW USER NAME:    
              &lt;input type="text" name="UserName" id="txNewUserName"     runat="server" /&gt;&lt;/p&gt;
          &lt;p&gt;NEW PASSWORD:
              &lt;input type="password" name="NewPassword" id="txPassword" runat="server" /&gt;&lt;/p&gt;
          &lt;p&gt;CONFIRM PASSWORD:
              &lt;input type="password" name="ConfirmPassword" /&gt;&lt;/p&gt;
          &lt;p&gt;FIRST NAME:    
              &lt;input type="text" name="FirstName" id="txFirstName" runat="server" /&gt;&lt;/p&gt;
          &lt;p&gt;LAST NAME:    
              &lt;input type="text" name="LastName" id="txLastName" runat="server" /&gt;&lt;/p&gt;
          &lt;p&gt;E-MAIL ADDRESS:    
              &lt;input type="text" name="eMail" id="txEmailAddress" runat="server" /&gt;&lt;/p&gt;
          &lt;p&gt;
              &lt;button class="mainButton" onclick="CreateUserName" value="CREATE USER" id="btCreateUser" runat="server" /&gt;&lt;/p&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is the CodeBehind:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using MongoDB.Bson;
  using MongoDB.Driver;
  
  namespace Project1.Pages
  {
  public partial class CreateUser : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
  
  
      }
      protected void CreateUserName(object sender, EventArgs e)
      {
  
          MongoClient client = new MongoClient();
          var db = client.GetDatabase("Projectdb");
          var coll = db.GetCollection&lt;User&gt;("User");
          User user = new Project1.User();
          user.userName = txNewUserName.Value;
          user.password = txPassword.Value;
          user.firstName = txFirstName.Value;
          user.lastName = txLastName.Value;
          user.eMail = txEmailAddress.Value;
  
          //validation if user exist
  
          coll.InsertOneAsync(user);
      }
  }
  }
  </code></pre>
  
  <p>Any help will be greatly appreciated.</p>