26.6.2 따라하기

    1. Visual Studio로 C:\ASP.NET\DotNetNote 프로젝트를 연다.

    2. DotNetNote 웹 프로젝트의 Controllers 폴더에 DemoController.cs 파일로 컨트롤러 클래스를 만들고, 다음과 같이 ContentResultDemo 액션 메서드를 추가로 작성한다. View() 메서드 값을 반환하지 않고 Content() 메서드로 일반적인 문자열을 반환할 수 있다.

    ▼  Controllers/DemoController.cs 파일의 ContentResultDemo 액션 메서드

    using Microsoft.AspNetCore.Mvc;
    using System;
    
    namespace DotNetNote.Controllers
    {
      public class DemoController : Controller
      {
          public IActionResult Index()
          {
              return View();
          }
          
          public IActionResult ContentResultDemo()
          {
              return Content(“ContentResult 반환값”);
          }
      }
    }
    

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.