본문 바로가기
728x90
반응형

ASP.NET MVC22

ASP.NET] 로그인 체크, 접속권한 체크 로그인을 해야지만 접속이 가능한 Controller에 상속한 BaseController를 만든다. 1. BaseController.cs public class BaseController : Controller { public string actionName { get; protected set; } public string controllerName { get; protected set; } protected override void OnActionExecuting(ActionExecutingContext filter) { //로그인 체크 LogonCheck(filter); //DoNotAuthorizeAttribute가 설정되어 있으면 접속권한 체크하지 않는다. if (filter.ActionDescr.. 2021. 12. 21.
ASP.NET] 게시판 Paging 페이징 만들기 1. NoticeList.cshtml @Html.Raw(PagingManager.Paging(ViewBag.page, ViewBag.totalCount, ViewBag.pageSize, ViewBag.url.ToString())) 2. PagingManager.cs public static string Paging(int iPageNo, int iRecordCount, int iPageSize, string iUrl) { string str = ""; if (iRecordCount > 0) { string strTotalCount = string.IsNullOrEmpty(string.Format("{0:#,###}", iRecordCount)) ? "0" : string.Format("{0:#,###}".. 2021. 12. 21.
ASP.NET] Select 태그 만드는 다양한 방법 (DropDownList, DropDownListFor, EnumDropDownListFor) cshtml 파일에 Select 태그를 만들때 다양한 방법을 사용할 수 있다. html Select 태그를 활용할 수 있고, SelectExtensions 클래스의 확장메서드를 사용하여 Select태그를 만들 수 있다. 1. html Select 태그 활용 선택 경력 신입 2. SelectExtensions 클래스의 확장 메서드 사용 (ASP.NET MVC 5.2) 2-1. DropDownList 활용 현재년도 ~ 2010년까지 나열되는 DropDownList를 만들어보자 2-1-1. ViewBag 활용 Controller에서 아래와 같이 만든다음 ViewBag.yearList에 할당한다. items.Add(new SelectListItem { Text = "년도", Value = "" }); for (.. 2021. 12. 8.
ASP.NET] 경로 노출없이, idx로 파일정보 조회하여 ZIP 다운로드 처리 public ActionResult ResumeDownload(int idx) { try { DataSet ds = DataAccess.Get_FileInfo(idx); //idx로 db에서 파일정보 가져오기 string fileName = ds.Tables[0].Rows[0]["FileName"].ToString(); //파일명 var filePath = Server.MapPath(AttachFilePath.AttachedFilePath + fileName); //파일경로 가져오기 if (System.IO.File.Exists(filePath)) //파일 존재여부 확인 { PersonalInfoLog log = new PersonalInfoLog log.Desc = "이러쿵 저러쿵 해서 개인정보 파일 .. 2021. 12. 6.
728x90
반응형