ASP.NET Core
-
[ASP.Net Core] 접속자 IP 받기Microsoft .NET/ASP.Net & ASP.Net Core 2021. 7. 16. 14:35
"Startup.cs" 클래스의 "ConfigureServices 함수"에 아래 코드 추가 public void ConfigureServices(IServiceCollection services) { #region IP services.AddSingleton(); #endregion services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } IP를 받을 Controller에 아래 코드를 추가하고 생성자 명을 본인 코드에 맞게 변경합니다. /// /// 생성자 /// /// public UserController(Microsoft.AspNetCore.Http.IHttpContextAccessor _acc) { HttpCont..
-
[ASP.Net Core API] File Upload API / 파일 업로드 APIMicrosoft .NET/ASP.Net & ASP.Net Core 2021. 2. 3. 11:23
파일 저장 경로, 저장 파일 명, 파일을 필수값으로 받아서 서버에 저장하는 API API that receives file storage path, save file name, and file as required values and saves them to the server #region Upload /// /// 파일 업로드 /// /// 파일 저장 경로(서버) /// 파일 저장 이름(서버) /// 파일(클라이언트) /// //[EnableCors("CORS")] [HttpPost("upload")] public string Upload( [Required][FromForm(Name = "path")]string path, [Required][FromForm(Name = "filename")]str..
-
[ASP.Net Core API] API 주소 설정Microsoft .NET/ASP.Net & ASP.Net Core 2020. 9. 17. 22:29
Controller 주소 및 API 주소 일괄 설정 - Controller Class 상단에 표기 ControllerClass 명칭 과 API함수 명칭을 자동으로 주소로 사용 : [Route("[controller]/[action]")] Ex) sample/member 더보기 [Route("[controller]/[action]")] [ApiController] public class sampleController : ControllerBase { //// GET: sample/member [HttpGet] public string member() { return "Virtualgiraffe"; } } Controller 주소 설정 - Controller Class 상단에 표기 Controller Cla..
-
[ASP.Net Core] Synology Nas Docker에 ASP.Net Core 게시하기Microsoft .NET/ASP.Net & ASP.Net Core 2020. 1. 29. 19:02
준비물 : SynologyNas, putty, VisualStudio 1. ASP.Net Core 프로젝트 생성 [설정값 : ASP.NetCore 2.0, MVC, docker:Linux] 2. Dockerfile 값 변경 3. 프로젝트 게시 4. Synology Nas에 게시된 파일 업로드 및 Docker 설치 5. putty를 사용하여 SynologyNas에 설치 1. ASP.Net Core 프로젝트 생성 [설정값 : ASP.NetCore 2.0, MVC, docker:Linux] 2. Dockerfile 값 변경 FROM microsoft/aspnetcore:2.0.0 COPY . /app WORKDIR /app #7552 = 포트번호!! ENV ASPNETCORE_URLS http://*:7552..