본문 바로가기

Web_Application/ASP.NET MVC

(11)
[C#] __RequestVerificationToken 에 path 지정 AntiForgeryToken 커스텀 함수 1. 목적 __RequestVerificationToken 의 쿠키의 경우 기본 path 가 '/' 잡혀 request 마다 따라 다니게 되는데 실제로 폼 인증에 1회성으로 밖에 사용하지 않는데도 무신경하게 놔두는데 불필요하게 request 트래픽만 잡아 먹고 있으니 필요한 곳에서만 쓰게 제한할 필요가 있다. 2. 구현 이미 기본형을 구현해 놓은 링크가 있어서 최근 버전에 맞게 수정했다. 원문 : https://colinnewell.wordpress.com/2009/01/28/tweaking-the-antiforgerytoken-on-aspnet-mvc/ 수정 소스 using System; using System.Collections.Generic; using System.Linq; using Syste..
asp.net mvc ajax post 500 error javascript var formCollection = $("#frmUser").serialize(); $.post("/UserInfo/ValidateUser", formCollection, function (status, textStatus, jqXHR) { if (status.Success) { alert("OK"); } else { alert("FAIL"); } }); controller [HttpPost]public JsonResult ValidateUser(FormCollection formValues){ JsonResult result = new JsonResult(); stirng param1 = formValues["param1"]; stirng param2 = formValues["pa..
bundle 403 error bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/css/Kcommon.css", "~/Content/css/Kmain.css", "~/Content/css/Ksub.css", "~/Content/css/Kboard.css")); ~/Content -> ~/bundles 로 변경 bundles.Add(new StyleBundle("~/bundles/css").Include( "~/Content/css/Kcommon.css", "~/Content/css/Kmain.css", "~/Content/css/Ksub.css", "~/Content/css/Kboard.css"));
Log4net 설치 Package InstallNuget Package Manager > log4net > Install Solution Explorer > Properties > AssemblyInfo.cs [assembly: log4net.Config.XmlConfigurator(Watch = true)] Web.config 소스 적용 예) Solution Explorer > Controllers > OOOController.cs
[ASP.NET MVC] Make sure that the controller has a parameterless public constructor 유발소스 ASP.NET MVC /Controller/FileController.cs public string storageRoot { get; set; } public FileController() { storageRoot = Server.MapPath("~/App_Data/Upload"); } public FileController(ServerPathProvider pathProvider) { storageRoot = pathProvider.MapPath(); } public string DoSomething(string path1, string path2, string filename) { return StorageRoot + "\\" + path1 + "\\" + path2 + "\\" + file..
Error 1053: "The service did not respond in a timely fashion" when attempting to start, stop or pause a service Windows 환경에서 서비스로 등록 시 정상적으로 등록이 되지 않을 때 1. Start > Run > regedit 실행 2. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control 3. control 폴더 우클릭 > 새로만들기 DWORD 이름 ServicesPipeTimeout 4. ServicesPipeTimeout 우클릭 후 수정 5. 10진수 (Decimal) 선택 '180000' 입력 후 OK 6. 리부팅
Upgrading mvc4 to mvc5 in vs2013 mvc4 -> mvc 5.2.3.0nuget package manager > asp.net mvc인스톨 되어 있으면 솔루션 탐색기 참조에서 System.Mvc 의 버전 체크 4.0.0.0 이면 System.Web.Mvc 참조 삭제 후 해당 솔루션 밖 패키지 폴더에서패키지 폴더 > Microsoft.AspNet.Mvc.5.2.3 > lib > net45 > System.Web.Mvc.dll 참조 추가 NuGet Package Console 창에서 Install-Package -Id Microsoft.AspNet.WebHelpers Install-Package Microsoft.AspNet.Web.Optimization Install-Package Microsoft.AspNet.WebPages.Data In..
JSON JavaScriptSerializer를 사용하여 serialize 또는 deserialize하는 동안 오류가 발생했습니다. 문자열의 길이가 maxJsonLength 속성에 설정된 값을 초과합니다. ASP.NET MVC 작업 중 JSON 으로 반환 받을때 serialize / deserialize 시에 생성되는 문자열의 길이에 제한이 있습니다. #1 인터넷에 가장많이 검색되는 방법으로 전역적으로 설정하는 방법 #2 해당 요청에만 설정하며 적용하는 방법 출처 : http://rion.io/2013/04/28/handling-larger-json-string-values-in-net-and-avoiding-exceptions/ JsonResult returnJsonResult = new JsonResult(); returnJsonResult = Json(resultList); returnJsonResult.MaxJsonLength = 2147483647; return returnJsonResult;