title: How can I scan for virus in Azure App Service when uploading a file using MVC not using a third pary API with C#?
body: <p>How can I scan for virus in Azure App Service (Azure Web Sites) when uploading a file using MVC not using a third pary API such as VirusTotal with C#?</p>
  
  <p>Is it possible to run Windows Defender?</p>
  
  <pre><code>&lt;form action="" method="post" enctype="multipart/form-data"&gt;
  
    &lt;label for="file"&gt;Filename:&lt;/label&gt;
    &lt;input type="file" name="file" id="file" /&gt;
  
    &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>CS example code, is it possible to run mpcmdrun.exe?</p>
  
  <pre><code>[HttpPost]
  public ActionResult Index(HttpPostedFileBase file) {
  
    if (file.ContentLength &gt; 0) {
      var fileName = Path.GetFileName(file.FileName);
      var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
      file.SaveAs(path);
  
      //Scan for Virus
      var virusScanner = new VirusScanner()
      var results = virusScanner.Scan(path);
      if(results.Viruses.Any())
      {
          File.Delete(path);
      }
    }
  
    return RedirectToAction("Index");
  }
  </code></pre>