ASP.NET CORE MVC Architecture

ASP.NET Core MVC
[quads id=RndAds] ASP.NET CORE MVC ArchitectureIn this tutorial will discuss what is mvc and architecture of mvc.MVCThe Model-View-Controller (MVC) architectural pattern separates an application into three main components: Models, Views, and Controllers. This pattern helps to achieve separation of concerns. Almost all the languages use MVC with slight variation, but conceptually it remains the same.Using this pattern, user requests are routed to a Controller which is responsible for working with the Model to perform user actions and/or retrieve results of queries. The Controller chooses the View to display to the user, and provides it with any Model data it requires.ModelThe Model in an MVC application represents the state of the application and any business logic or operations that should be performed by it. A model can also contain the logic…
Read More

ASP.NET CORE Serving Static Files

ASP.NET Core Tutorials
[quads id=RndAds] ASP.NET CORE Serving Static FilesIn this tutorial will discuss how to get static files which require for our application like CSS, html, JS and images.Static files are required for your application such as JavaScript files, CSS files, html files and images or icons. Serving Static FilesStatic files are typically located in the web root (wwwroot) folder and its default place where we can serve up files directly from the file system when we create your asp.net core applicationStatic files can be stored in any folder under the web root and accessed with a relative path to that root. For example, when you create a default Web application project using Visual Studio, there are several folders created within the wwwroot folder - css, images, lib and js.Let us take a…
Read More

ASP.NET CORE Developer Exception Page

ASP.NET Core Tutorials
[quads id=RndAds] ASP.NET CORE Developer Exception PageIn this tutorial will discuss what is developer exception page and how its useful to the development environment.What is developer exception pageIn ASP.NET Core application simple returns a status code for an exception that is not handled by the application. Let's switch to the visual studio and understand how to do this with an example.Lets modify the Configure() method of the startup class and middleware where we throw an exception.public class Startup {    public void Configure(IApplicationBuilder app, IHostingEnvironment env) {               app.Run(context => { throw new Exception("GTechFluent:Developer exception page: Error"); }); } }Once run application you will get below screen it gives you the status code as 500 which means Internal Server Error. But as a developer when you are developing the application, you should…
Read More

ASP.NET CORE Dependency Injection

ASP.NET Core Tutorials
[quads id=RndAds] ASP.NET CORE Dependency InjectionIn this tutorial will discuss what is dependency injection and how its work in net core.Dependency Injection (DI): its a software design pattern that allows us to develop loosely coupled code. Dependency Injection is a great way to reduce tight coupling between software components. Dependency Injection also enables us to better manage future changesand other complexity in our software. The purpose of DI is to make code maintainable.Tightly Coupling: The software components were dependent on each other in such a way that, for a small change in one component, you might need to change a lot in the dependent component. This is not good practice in software development. Simplest way to understand is when we get an instance by using a new keyword that class…
Read More

Asp.net core configuration environment variables

ASP.NET Core Tutorials
[quads id=RndAds] ASP.NET CORE Configuration Environment VariablesIn this tutorial will discuss how configure environment variables and use of the environment variables.Typically, in professional application development, there are multiple phases where an application is tested before publishing it to the real users. These phases by convention are development, staging, and production. We as developers might like to control the behavior of an application based on the phases the application is in. Environment variable indicates the runtime environment in which an application is currently running.Why do we need different Environments like Development, Staging, Production etc.Development Environment : We software developers typically use this environment for our day to day development work. We want non-minified JavaScript and CSS files to be loaded on a development environment to make debugging easy.Staging Environment : Most…
Read More

ASP.NET CORE Configuration

ASP.NET Core Tutorials
[quads id=RndAds] ASP.NET CORE ConfigurationIn this tutorial will discuss different ways of storing the configuration and read the configurations. We will discuss below point step by step.Different ways of storing configuration.Default Configuration.Adding Configuration Files.Read Configuration.In ASP.NET CORE, the WEB.CONFIG file was totally out of use, but if you want to Host an ASP.NET CORE Web Application on IIS, you must need to still use it. Different ways of storing configurationInstead of web.config, The configuration of an ASP.NET Core application is based on a list key-value pairs collected at runtime from a variety of data sources. Such asSettings Files (JSON(),XML, INI)Command-line argumentsEnvironment variablesIn-memory .NET objectsAzure Key VaultWe can also create custom providers and add them into our ASP.NET Core application. You might be worried about how to manage to add files and…
Read More

ASP.NET CORE Attribute Routing

ASP.NET Core Tutorials
[quads id=RndAds] ASP.NET CORE Attribute Routing Youtube In this tutorial will discuss attribute routing and will understand when choose between attribute routing and conventional based routingAttribute routing allows us developers to define routes right next to the actions they map to. This allows for us to get very fine-grained control over what routes map to which actions.As with convention-based routing, the routes are still evaluated against URLs, but unlike in convention-based routing, all routes are evaluated at the same time, in order to find the best match. Because of this, attribute routing wants us to be very specific when defining routes and route patterns.Setup Attribute Routing.In order to use attribute routing in ASP.NET Core 3.1, we need to do two things in our Startup.cs file.First, just like with convention-based routing,…
Read More

ASP.NET CORE EndPoint Routing

ASP.NET Core Tutorials
[quads id=RndAds] ASP.NET CORE EndPoint Routing Youtube In this tutorial will discuss new asp.net core endpoint routing feature  that has added in ASP.Net core Middleware pipeline from asp. Net core 2.2 and above versions.Let's understand the how asp.net core 2.1 and below version routing configure. In Asp.Net Core version 2.1 or below routing is configured using app.UseMvcWithDefaultRoute() or app.UseMvc() middleware. This must be configured at end of requests pipeline. app.UseMvcWithDefaultRoute(); app.UseMvc(routes => {     routes.MapRoute(         name: "default",         template: "{controller=Home}/{action=About}/{id?}"); }); The problem with is an operation or functionality which is dependent on route URL or route values and that need to be implemented before the execution of route Middleware and can be done by accessing the route path from the current request context instead of route data.In Above…
Read More

Routing Techniques In ASP.NET CORE

ASP.NET Core Tutorials
[quads id=RndAds] Routing Techniques In ASP.NET COREIn this tutorials will discuss and understand how routing is worked in asp.net core.RoutingRouting in ASP.NET Core is the process of mapping incoming requests to application logic that are resides in controllers and methods.ASP.NET Core maps the incoming request based on the routes that you configure in your application, and for each route, you can set specific configurations, such as default values, message handlers, constraints Routing Techniques   Conventional routing: The route is determined based on conventions that are defined in route templates, at run time, it will will map requests to the controllers and actions or methods. Attribute-based routing: The route is determined based on attributes that you set on your controllers and methods. Routing Process  When a request came from the browser at our application, the controller in…
Read More

ASP.NET CORE Middleware

ASP.NET Core Tutorials
[quads id=RndAds] ASP.NET CORE MiddlewareIn this tutorials will discuss and understand what is the middleware and significant of the middleware's.What is Middleware ASP. NET Core? In ASP.NET Core, Middleware is a piece of code that are assembled into an application pipeline to handle an HTTP request or response. A given middleware component in ASP.NET Core has a very specific purpose. That means when we create as or add any middleware that is for Some specific purpose For example we may have a middleware component that authenticates a user, another piece of middleware to handle errors, yet another middleware to serve static files such as JavaScript files, CSS files, Images etc. In ASP.NET Core, a Middleware component has access to both the incoming request and the outgoing response. So a Middleware component may process…
Read More