title: HtmlSanitizer + ASP.NET Core 2 with DI
body: <p>When I use <a href="https://github.com/mganss/HtmlSanitizer" rel="nofollow noreferrer">HtmlSanitizer</a> without DI it works well.</p>
  
  <p>HtmlSanitizer without DI:  </p>
  
  <p><a href="https://i.stack.imgur.com/6NPNn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6NPNn.png" alt="HtmlSanitizer without DI"></a></p>
  
  <p>But when I want to get <code>HtmlSanitizer</code> using DI.</p>
  
  <ol>
  <li><p>I added to Startup.cs file:</p>
  
  <pre><code>services.AddSingleton&lt;IHtmlSanitizer, HtmlSanitizer&gt;();
  </code></pre></li>
  <li><p>I used constructor of repository to get instance of <code>IHtmlSanitizer</code> but
  in the injected <code>HtmlSanitizer</code> instance, <code>AllowedTags</code>, and <code>AllowAttributes</code> are empty.</p></li>
  </ol>
  
  <p>HtmlSanitizer with DI:  </p>
  
  <p><a href="https://i.stack.imgur.com/yyMyM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yyMyM.png" alt="HtmlSanitizer with DI"></a></p>
  
  <p>How can I get <code>HtmlSanitizer</code> with filled properties using DI?</p>