Skip to main content

Posts

Choosing Between .NET Minimal APIs and Controllers: A Practical Guide

          .NET Minimal APIs and Controllers Controllers: Structured and Versatile What are Controllers?  Controllers have been a fundamental part of ASP.NET API development for years. They follow the MVC (Model-View-Controller) pattern and provide a structured way to organize endpoints, models, and business logic within dedicated controller classes. Advantages of Controllers : Structure and Organization : Controllers offer a clear separation of concerns, enhancing maintainability. Flexibility : They allow custom routes, complex request handling, and support various HTTP verbs. Testing : Controllers facilitate unit testing of individual actions, promoting a test-driven approach. Here’s an example of a controller-based approach: [ApiController] [Route("api/[controller]")] public class ProductsController : ControllerBase {     private readonly IProd...

.NET 8 Minimal APIs: A Step-by-Step Guide

                      .NET 8 Minimal APIs                 In the ever-evolving world of software development, .NET 8 brings a fresh approach to building APIs with its Minimal API feature. This streamlined framework allows developers to create lightweight, high-performance APIs with minimal setup and configuration. In this blog post, we’ll explore the key features of .NET 8 Minimal APIs and walk through the steps to create your first minimal API. Why Minimal APIs?      Minimal APIs in .NET 8 are designed to simplify the development process by reducing boilerplate code and focusing on the essentials. Here are some benefits: Simplicity : Minimal APIs require less code and configuration, making them easier to set up and maintain. Performance : With fewer abstractions, Minimal APIs can offer better performance. Flexibility : Ideal for microservices and small appli...

Send Meeting Invitation with C#

    So you know how to  send an email using C#  but now if you would like to attach an invitation to a meeting. We need to follow the below steps to accomplish this and it will work for the emailing apps like Outlook and Gmail.      In this code snippet I will be using an ICS(Internet Calendar Scheduling) or an iCal format for the invitation. What is ICS      An ICS (Internet Calendar Scheduling) file is a calendar file with an universal calendar format and it is used by several email providers and calendar programs, including Microsoft Outlook, Google Calendar, Notes and Apple Calendar. It enables users to publish and share calendar information on the web and over email. ICS files are often used for sending meeting requests to other users, who can import the events into their own calendars. To Send calendar invitation we need to use the System.Net.Mail namespace in .Net. And the classes required to send calendar invite are Alternat...

C# Send Email via SMTP

Simple Mail Transfer Protocol (SMTP) Simple Mail Transfer Protocol (SMTP) is a TCP/IP protocol used in sending and receiving e-mail. Most of the e-mail systems that send mail over the Internet use SMTP to send messages from one server to another. The messages can then be retrieved with an e-mail client using either POP or IMAP. SMTP Class in C#:  MailMessage class is part of the namespace System.Net.Mail and it is used to create the email messages that are sent to the SMTP Server. The delivery of the message will be taken care by the SmtpClient Class. SMTP Class Properties: Host:  Server URL for SMTP EnableSsl:  True or False. Port:  Port Number of the SMTP server Credentials:  Valid login credentials for the SMTP server (the email address and password). UseDefaultCredentials:  When we set to True then that specifies to allow authentication based on the credentials of the account used to send emails. Below are the list of few SMTP Server and Port ...