기존에 Kestrel 서버만 별도로 사용 하는 서버에서 웹페이지를 띄우고 싶은 생각에
WebApplication.Services.AddControllersWithViews()을 별도로 등록 하여 Controller와 View Page를 구성하여
[ 프로젝트 구성 ]
1. Program.cs
...
WebAppBuilder.Services.AddControllersWithViews();
...
2. Controllers/TestController.cs [ Index는 View Page를 따라 간다. 즉, Index.cshtml ]
public class TestController : Controller
{
public IActionResult Index() { return View(); }
}
3. Views/Test/Index.cshtml [ Test는 Controller를 따라 간다. ]
@{
ViewData["Title"] = "Home";
}
<h1>Welcome to My Web App!</h1>
접속 하면 웹페이를 띄울 수 있는 것처럼 보였다.
하지만 접속 하면 아래 그림과 같이 에러가 뜨는데
에러를 잘보면 Controller 까지 접속은 잘 들어오나 View Page 경로를 못 찾는 경우를 확인 할 수 있다.

[ Exception 메시지 ]
InvalidOperationException: The view 'Index' was not found. The following locations were searched: /Views/Test/Index.cshtml /Views/Shared/Index.cshtml
Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable<string> originalLocations)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
잘 안되어서 구글링 해보고 삽질 한 끝에 <링크> 찾아 적용 해보니 페이지가 정상적으로 잘 떳다.
[ 프로젝트 구성 ]
1. "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" 패키지 설치
2. Program.cs 수정
...
WebAppBuilder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();
...
[ 정상적 페이지 ]

이러한 문제 들을 마주 하기 도 할 것 같은 분들도 있을 것 같고 고생 끝에 찾은 거다보니 기록 할겸 정리해서 남깁니다.