concept html in category .net

appears as: HTML, HTML
.NET Core in Action

This is an excerpt from Manning's book .NET Core in Action.

To handle the storing of posts and conversion from Markdown to HTML, I created a microservice. To describe what a microservice is, I’ll borrow some of the characteristics listed in Christian Horsdal Gammelgaard’s book Microservices in .NET Core (Manning, 2017). A microservice is

Listing 7.6. MdlController accepts Markdown text and returns HTML
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.DocAsCode.MarkdownLite;

namespace MarkdownService
{
  [Route("/")]                                             #1
  public class MdlController : Controller
  {
    private readonly IMarkdownEngine engine;

    public MdlController(IMarkdownEngine engine)           #2
    {
      this.engine = engine;
    }

    [HttpPost]                                             #3
    public IActionResult Convert()
    {
      var reader = new StreamReader(Request.Body);         #4
      var markdown = reader.ReadToEnd();                   #5
      var result = engine.Markup(markdown);
      return Content(result);                              #6
    }
  }
}

Now try out some sample code. The following listing shows a test to convert simple Markdown text into HTML and write the HTML to the console.