.NET/ASP.NET

    [ASP.NET Core] MVC Pattern

    [ASP.NET Core] MVC Pattern

    MVC는 Model, View, Controller를 의미하는 것으로 이 3개의 구조를 통해 web project가 완성되는 것을 말합니다. 해당 구조의 간단한 예를 만들어 보기 위해 가상의 website에서 login 하는 과정으로 mvc pattern구조를 적용해 보도록 하겠습니다. Visual Studio 2019를 시작해 새 project에서 'ASP.NET Core Empty'를 선택합니다. project이름 따윈 중요하지 않으므로 대충 입력하고 넘어갑니다. project는 아무것도 없는 상태에서 시작하므로 몇 가지 사전 설정이 필요합니다. project에서 startup.cs file을 열고 다음과 같이 수정합니다. namespace WebApplication1 { public class St..

    [ASP.NET Core]IIS Express 인증서 재발행

    예) 발행하고자 하는 주소가 https//localhost:44387인 경우 Cmd에서 C:\Program Files (x86)\IIS Express IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:44387/ -UseSelfSigned

    [ASP.NET Core] Microsoft.Data.SqlClient.SqlException (0x80131904)

    Linux환경 하에서 작동하는 ASP.NET Core 5 웹서비스에서 Windows Server의 MSSQL Server 접속 시 아래와 같은 오류가 발생하는 경우 Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed) MSSQL Server에서 TLS1.2 연결이 지원되는지 확인해야 합니다. 해당 문제점이 발생된 사레로는 MS..

    [ASP.NET Core Web API] Swagger에 JWT인증 적용하기

    [ASP.NET Core Web API] Swagger에 JWT인증 적용하기

    프로젝트의 Start.cs -> ConfigureServices() 메서드에 다음과 같은 설정코드를 추가합니다. var securitySchema = new OpenApiSecurityScheme { Description = "다음과 같은 형식으로 JWT Authorization header에 토큰을 보내도록 합니다. \"Authorization: Bearer {token}\"", Name = "Authorization", In = ParameterLocation.Header, Type = SecuritySchemeType.Http, Scheme = "bearer", Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = ..

    [ASP.NET Core] ASP.NET Core API에 ReactJS 배포하기

    [ASP.NET Core] ASP.NET Core API에 ReactJS 배포하기

    1. NuGet Package에서 Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer를 찾아 설치합니다. 2. Project의 Startup.cs파일에서 다음과 같은 코드를 추가하여 정적 파일 서비스를 등록하고 사용할 수 있도록 설정합니다. --ConfigureServices services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; }); --Configure app.UseDefaultFiles(); app.UseStaticFiles(); app.UseSpaStaticFiles(); . . . . app.UseSpa(spa => { spa.Options...

    [ASP.NET Core] MailKit 사용

    'MailKit'이라는 이름으로 프로젝트에 NuGet package를 추가합니다. //발신자 설정 MailboxAddress from = new MailboxAddress("이름(생략가능)", "메일주소"); message.From.Add(from); //수신자 설정 MailboxAddress to = new MailboxAddress("이름(생략가능)", "메일주소"); message.To.Add(to); //메일제목 message.Subject = "안뇽~"; //메일본문 BodyBuilder bodyBuilder = new BodyBuilder(); bodyBuilder.HtmlBody = "반가워~"; //필요한 경우 첨부파일 //bodyBuilder.Attachments.Add("C:\\file..

    [ASP.NET Core Web API] 'IAsyncEnumerable Reader' reached the configured maximum size of the buffer when enumerating a value of type

    API 요청 시 아래와 같은 오류가 발생한다면 'IAsyncEnumerable Reader' reached the configured maximum size of the buffer when enumerating a value of type Startup.cs에서 다음과 같이 MaxIAsyncEnumerableBufferLimit 설정값을 늘려줍니다. public void ConfigureServices(IServiceCollection services) { services.AddControllers(mvcOptions => { mvcOptions.MaxIAsyncEnumerableBufferLimit = [값]; }); } [값] 부분에 원하는 값을 넣으면 되며 참고로 기본값은 8193입니다.

    [ASP.NET Core] IIS 호스팅

    [ASP.NET Core] IIS 호스팅

    IIS에서 다음과 같은 설정으로 응용프로그램풀을 추가합니다. 아래 주소에서 ASP.NET Core Runtime을 내려 받습니다. 2021.03월 현재 최신버전은 5.0인데 하위 Core 3.1을 배포하는 경우라도 상관없습니다. Download ASP.NET Core 5.0 Runtime (v5.0.4) - Windows Hosting Bundle Installer (microsoft.com) Download ASP.NET Core 5.0 Runtime (v5.0.4) - Windows Hosting Bundle Installer Supported on Windows, Linux, and macOS Get Started dotnet.microsoft.com IIS에서 웹사이트를 추가합니다. 프로젝트가 배..