Visual studio 2010 express 버전
- Test0821.Controllers 코드 수정
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Test0821.Controllers
{
public class Test0821Controller : Controller
{
//
// GET: /Home/
// public ActionResult Index()
//{
//return View();
//}
// 홈페이지상에서 보여질 문구
//public string Index()
//{
//return "안녕하세요?a~ HomeController 실?C행a했??습?A니?I다?U.";
//}
// View 추??가???하I기?a
public ViewResult Index()
{
return View();
}
}
}
- View 추가하기
- return View(); -> 우 클릭 -> Add View클릭
- Index.cshtml(View 파일) 추가된 모습
- Index.cshtml 코드 변경
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div>
안?E녕?c하I세???요?a! Index.cshtml 뷰?a 페?a이I지o입O니?I다?U.
</div>
</body>
</html>
- 디버깅 결과
- Test0821.Controllers 파일 코드 변경
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Test0821.Controllers
{
public class Test0821Controller : Controller
{
//
// GET: /Home/
// public ActionResult Index()
//{
//return View();
//}
// 홈??페?a이I지o상?o에???서??? 보???여???질u 문???구???
//public string Index()
//{
//return "안?E녕?c하I세???요?a~ HomeController 실?C행a했??습?A니?I다?U.";
//}
// View 추??가???하I기?a
public ViewResult Index()
{
string str_Message = "동???적u 출a력?A하I는?A 부?I분???입O니?I다?U.";
ViewBag.Hello = str_Message;
return View();
}
}
}
- Index.cshtml 코드 변경
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div>
안?E녕?c하I세???요?a! Index.cshtml 뷰?a 페?a이I지o입O니?I다?U.
</div>
@ViewBag.Hello
</body>
</html>
- 디버깅 결과
'ASP.NET > MVC 3' 카테고리의 다른 글
MVC 3 - InternetApplication으로 생성 시 에러 (0) | 2018.08.24 |
---|---|
ASP.NET MVC 3 MSSQL 연결하기 + Select (0) | 2018.08.23 |
ASP.NET MVC 3 MSSQL 연결하기 + INSERT (0) | 2018.08.23 |
ASP.NET MVC 3 Model 추가하기 (0) | 2018.08.23 |
.NET MVC 3를 이용한 기본 Controller 생성, View 템플릿 추가하기, 모델 이용하기, 페이지들 간의 링크 추가하기 (0) | 2018.07.19 |