.NET/ASP.NET

    [ASP.NET Core] 의존성 주입(Dependency Injection)

    [ASP.NET Core] 의존성 주입(Dependency Injection)

    흔히 '관심사의 분리'라 하는 것으로 MVC pattern의 가장 중요한 특징 중 하나에 해당합니다. program을 이루는 각 부분의 밀접도를 최소화하여 독립성을 유지하고자 하는 개념으로 new를 통해 곧바로 instance를 생성하는 것이 아니라 interface를 이용해 의존성 주입을 구현하고 이로 인해 program을 이루는 각 구성요소의 관심사를 최대한 분리하고자 하는 것이 핵심입니다. 응용 program의 상호의존성이 너무 강하면 하나의 변경사항으로 다른 쪽 수정사항을 유발하게 되고 또 그것으로 인해 생각지 못한 전혀 다른 부분에서의 수정 작업을 거쳐야 하는 등 비효휼적인 과정이 너무 많이 발생할 수 있습니다. 따라서 의존성을 줄이면 서로 간의 변경사항에 대한 영향력을 최소화할 수 있게 됩니다..

    [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입니다.