ASP .Net Core Basic Program Execution Program.Cs file basic code And Detail // Create a builder instance of WebApplicationBuilder class var builder = WebApplication.CreateBuilder(args); // Build the app (Return an instance of WebApplication) var app = builder.Build(); // Create a route - HTTP GET method + URL, returns "Hello World" app.MapGet("/", () => "Hello World!"); // Start the server app.Run(); When we start the execution of our ASP.NET console application, it begins from the `Program.cs` file. This file typically contains the `Program` class and the `Main` method. However, starting with C# 9, Microsoft removed the need for the `Program` class and the `Main` method. Instead, they introduced a simplified approach, and the application can now run with just four lines of code. Details about each line of code are provided in the comments above the code. Detail of each line: code Line 1 // Create a builder instance of WebApplicationBuilder class var builder = WebApplication.CreateBuilder(args); This line creates an instance of WebApplicationBuilder, which sets up configuration, logging, and services for the application. Code Line 2 // Build the app (Return an instance of WebApplication) var app = builder.Build(); After configuring services and middleware, you build the app using builder.Build(). This creates a WebApplication instance that is ready to run. Code Line 3 // Create a route - HTTP GET method + URL, returns "Hello World" app.MapGet("/", () => "Hello World!"); Here, you define a simple route using the MapGet() method. This maps the root URL ("/") to an HTTP GET request, which returns the string "Hello World!". Code Line 4 // Start the server app.Run(); Finally, the app.Run() method starts the web server, allowing it to listen for incoming requests.
WASEEM HAIDER’s Post
More Relevant Posts
-
Implement ASP.NET Core OpenID Connect OAuth PAR client with Keycloak using .NET Aspire https://lnkd.in/gBGZieRk Sach Tek
To view or add a comment, sign in
-
Implement ASP.NET Core OpenID Connect OAuth PAR client with Keycloak using .NET Aspire #SharpCoding #DotNET #Aspire
Implement ASP.NET Core OpenID Connect OAuth PAR client with Keycloak using .NET Aspire
http://damienbod.com
To view or add a comment, sign in
-
Implement ASP.NET Core OpenID Connect OAuth PAR client with Keycloak using .NET Aspire #SharpCoding #DotNET #Aspire
Implement ASP.NET Core OpenID Connect OAuth PAR client with Keycloak using .NET Aspire
http://damienbod.com
To view or add a comment, sign in
-
Implement ASP.NET Core OpenID Connect OAuth PAR client with Keycloak using .NET Aspire #SharpCoding #DotNET #Aspire
Implement ASP.NET Core OpenID Connect OAuth PAR client with Keycloak using .NET Aspire
http://damienbod.com
To view or add a comment, sign in
-
Implement ASP.NET Core OpenID Connect OAuth PAR client with Keycloak using .NET Aspire #SharpCoding #DotNET #Aspire
Implement ASP.NET Core OpenID Connect OAuth PAR client with Keycloak using .NET Aspire
http://damienbod.com
To view or add a comment, sign in
-
.NET 9 Preview 1 includes a few updates for ASP.NET Core, but it's important to remember this is a preview release. Here's a quick rundown of the new features: 1- Improved debugging for dictionaries and other key-value collections: This might seem like a minor update, but it can be a big time-saver for developers. Previously, the key and value would be concatenated together in the debugger, making it difficult to read. Now, the key is displayed in its own column for easier inspection. This applies to a variety of collections used throughout ASP.NET Core, including HTTP headers, query strings, and view data. 2- JSON polymorphic type support in SignalR Hubs: This is a more technical update, but it allows for more flexibility when working with JSON data in SignalR Hubs. SignalR is a real-time communication framework that enables bi-directional communication between a server and client. With this update, you can now use JSON data that includes polymorphic types, which means the type information can vary. Overall, the updates in .NET 9 Preview 1 for ASP.NET Core are focused on improving developer productivity and laying the groundwork for future features. You can find more details in the official Microsoft Docs. It's also worth noting that .NET 9 itself includes some performance enhancements that could benefit ASP.NET Core applications. These include improvements to the 64-bit JIT compiler and better support for Native AOT. #dotnet9 #dotnet9preview #aspnetcore9preview #dotnet #dotnetcore #aspnet #aspnetcore #dotnetdeveloper https://lnkd.in/eHfmhvmu
What's new in ASP.NET Core 9.0
learn.microsoft.com
To view or add a comment, sign in
-
Blogged: Implementing an ASP.NET Core API with .NET 9 and OpenAPI https://lnkd.in/dSHqaeP7 #aspnetcore #OAuth #openapi #net9 #dotnet
Implementing an ASP.NET Core API with .NET 9 and OpenAPI
http://damienbod.com
To view or add a comment, sign in
-
Using Coravel as a scheduler in ASP.NET Core https://lnkd.in/dUDh-bgx Scheduling one or more background tasks is almost inevitable when building robust, self-sustaining APIs with .NET. A few packages have been around for years, such as Hangfire and Quartz.NET. ASP.NET Core allows background tasks to be implemented as hosted services. However, you might need something more customizable and lightweight with a simplistic syntax. I present Coravel. Coravel is an open-source, lightweight library for .NET that allows you to easily perform background processing and scheduling in your ASP.NET Core application. Coravel helps developers get their .NET applications up and running fast by making advanced application features like task/job scheduling, queuing, caching, mailing (and more!) accessible and easy to use. [...] #aspnetcore #taskscheduling #backgroundservice #scheduling #coravel
Using Coravel as a scheduler in ASP.NET Core :: Articles :: Sergey Drozdov
sd.blackball.lv
To view or add a comment, sign in
-
Build an authentication handler for a minimal API in ASP.NET Core https://trib.al/HJ7s0b4
Build an authentication handler for a minimal API in ASP.NET Core
infoworld.com
To view or add a comment, sign in
-
Been building applications for a while now especially Asp. Net Core Web APIs and Web Application and my opinion or advice should I say based on experience is that most of the time you will hear people say or read on the internet that you don't have to know too much about C# and Web Architecture to start. I'm telling you now this is not the case. Firstly, you have to have a concrete understanding of C# especially OOP, Composition, Aggregation,Association, Lambda Expressions, Delegates ,Extension Methods ,IEnumerable and IQueryable Interfaces ,Asynchronous Programming, Exception Handling, Reflection and Attributes, LINQ and other Advanced Topics. Understanding all these will help you know what's working "Under the Hood" and that will really help you to understand the concept of IoC Dependency Injection, Services, Entity Framework , CQRS, Attributes etc. Secondly, who have to know how the web works, things like Web Architecture and the HTTP Stack are very important and some Networking knowledge of the OSI model. IP address and Ports are also vital to understand. If you know this things the concept of API or REST API ,Routing and Middleware will be easy for you to grasp. Finally, Read on Software Design Principles and Patterns this will help you build effective software.
To view or add a comment, sign in