저는 asp.net 코어의 초보자입니다. 나는 코드를 먼저 사용하여 접근 방법을 사용하여 CreateCustomerAccount.cshtml이라는보기 페이지를 만들고 CreateCustomerAccountController라는 뷰를 반환하는 컨트롤러를 추가했습니다. 그러나 컨트롤러는 html/view 내용 대신 공백 페이지를 반환합니다. 내가 뭐 잘못 했니? 여기 내보기 페이지가 mvc asp.net에 아무것도 표시되지 않습니다
는 CreateAccount.cshtml@{
ViewData["Title"] = "CreateCustomerAccount";
}
<h2>CreateCustomerAccount</h2>
<p>User can create account using a form later</p>
내 코드입니다 그리고 여기 내 CreateCustomerAccountController.cs 클래스
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace TimeSheetManagementSystem.Controllers
{
public class CreateCustomerAccountController : Controller
{
public IActionResult Index()
{
return View();
}
public IActionResult CreateCustomerAccount()
{
return View();
}
}
}
"CreateCustomerAccountController"라는 이름의 폴더에 있어야하며보기/페이지의 이름은 "Index.cshtml"또는 "CreateCustomerAccount.cshtml"이어야합니다. 동일한 구조입니까? – msoliman
당신의 메소드는'Index()'라는 이름을 가지므로'Index.cshtml' ('CreateCustomerAccount'는 컨트롤러가 아닌 컨트롤러의 이름입니다)라는 이름으로 보일 것입니다. 다른 방법으로는'return View ("CreateCustomerAccount");를 사용할 수 있지만, 아무 의미가 없습니다. –
정말 고마워요! 내보기 이름을 색인으로 변경하고 "Microsoft.AspNetCore.Authorization; 을 사용하여 Microsoft.AspNetCore.Mvc;"를 추가했습니다. " 그리고 그것은 작동합니다 – JApple