Text HTML in ASP.NET Core Web API

This project will demonstrate how to use Text HTML in ASP.NET Core Web API

  • LearnASPNETCoreWebAPIWithRealApps
    • Controllers
      • DemoController.cs
    • Startup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace LearnASPNETCoreWebAPIWithRealApps.Controllers
{
    [Route("api/demo")]
    public class DemoController : Controller
    {
        [Produces("text/plain")]
        [HttpGet("demo1")]
        public async Task<IActionResult> Demo1()
        {
            try
            {
                string result = "Hello World";
                return Ok(result);
            }
            catch
            {
                return BadRequest();
            }
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;

namespace LearnASPNETCoreWebAPIWithRealApps
{
    public class Startup
    {

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();
        }
    }
}

Screenshots