Skip to main content

Posts

Showing posts with the label asp.net core

Send an Email via SMTP with MailKit Using .NET 6

How to Send an Email in .NET Core This tutorial show you how to send an email in .NET 6.0 using the MailKit email client library. Install MailKit via NuGet Visual Studio Package Manager Console: Install-Package MailKit How to Send an HTML Email in .NET 6.0 This code sends a simple HTML email using the Gmail SMTP service. There are instructions further below on how to use a few other popular SMTP providers - Gmail, Hotmail, Office 365. // create email message var email = new MimeMessage(); email.From.Add(MailboxAddress.Parse("from_address@example.com")); email.To.Add(MailboxAddress.Parse("to_address@example.com")); email.Subject = "Email Subject"; email.Body = new TextPart(TextFormat.Html) { Text = "<h1>Test HTML Message Body</h1>" }; // send email using var smtp = new SmtpClient(); smtp.Connect("smtp.gmail.com", 587, SecureSocketOptions.StartTls); smtp.Authenticate("[Username]", "[Password]"); smtp.Se

CRUD operations in web api using net 6.0

.NET 6.0 - CRUD API Example and Tutorial This tutorial gives you step by step implementation of creating CRUD operations using ASP.NET Web API Core. This tutorial builds API for its clients to manage employee. it shows how to configure the SQL server connection to manage CRUD operations in real-time applications. Let's start step by step. 1. Create ASP.NET Web API Project Open your Visual Studio and select New Project from File Menu.     Now enter the name of the application and click next.   Next select framework .net 6 from drop down and enable open API (Swagger) support and click on create to create default project template for API.   2. Now Add Model to Employee Web API In this step, you will add the Employee Model Class which will define database entity. Right click on the project from solution explorer and select Add -> New Folder . Enter folder name as Models . Right click on the Models folder and select Add -> Class and add class file with name

ASP.NET Core - Overview

What is ASP.NET Core? ASP.NET Core is a web framework created by Microsoft for building web applications, APIs, and microservices. It uses common patterns like MVC (Model-View-Controller), dependency injection, and a request pipeline comprised of middleware. It's open-source under the Apache 2.0 license, which means the source code is freely available, and the community is encouraged to contribute bug fixes and new features. ASP.NET Core runs on top of Microsoft's .NET runtime, similar to the Java Virtual Machine (JVM) or the Ruby interpreter. You can write ASP.NET Core applications in a number of languages (C#, Visual Basic, F#). C# is the most popular choice. You can build and run ASP.NET Core applications on Windows, Mac, and Linux. Why do we need another web framework? There are a lot of great web frameworks to choose from already: Node/Express, Spring, Ruby on Rails, Django, Laravel, and many more. What advantages does ASP.NET Core have?  Speed . ASP.NET Core is fast. Bec