April 12

0 comments

Asp.net core -1 Minute guide

By Gulab Chand

April 12, 2022

Asp.net core -1 Minute guide

Do you want to be a successful developer?

If you said yes, then I have some news for you…

The future is here…

Today, we are going to talk about asp.net core and what it can bring to you. We are going to see how asp.net core allows us to do things like implement authentication, database access, and much more.

This article is a summary of a few minutes of my daily work with.NET Core, but I think it’s going to be useful for you too.

What is asp.net core?

Asp.net core is a cross-platform development framework for building web applications. It was created by Microsoft with the purpose of providing a simple platform for developing modern web applications.

What is it used for?

If you are building a new application, then you definitely should consider asp.net core. Why? Because it allows you to create modern, secure, and scalable web applications in a very simple way. In other words, you don’t need to know anything about the back-end part of your application (how it works, or how you configure it). You just need to know what features your application needs to provide to its users. That’s why asp.net core is perfect for all kinds of scenarios, be it mobile or desktop, or any other type of web application.

It allows you to build REST APIs, web forms, and everything in between. So if you are familiar with MVC, then you already know what it can do.

Another thing that asp.net core brings to the table is that you can use the same codebase on Linux, Windows, or Mac.

When you install the.NET Core SDK, you also get the Visual Studio 2019 IDE, which is what we are using today. This means that we will only use the visual part of the IDE, but you will still be able to run your project from the command line (command prompt, Terminal, Powershell, etc.).

Let’s look at the main features of asp.net core:

MVC

ASP.NET Core offers a framework that is similar to the MVC model of the ASP.NET Framework. However, there are some differences between these two frameworks, which we will be explaining soon.

Model View Controller

The basic structure of an asp.net application is the Model View Controller. A controller controls the view, and a view represents the user interface.

ASP.NET Core’s MVC is actually a bit more complicated. Instead of having controllers, there is a separate layer called Dependency Injection (DI). This layer is responsible for instantiating and configuring objects in your application.

In the MVC framework, the controllers were responsible for configuring the views. The DI layer does this in asp.net core.

Authentication

One of the biggest problems when it comes to writing web applications is the security aspect. You have to make sure that no one else is going to be able to access your data, or that your website will not be hacked.

ASP.NET Core has built-in support for authentication. With this, you do not have to worry about authenticating your users yourself. You just need to provide a username and password, and the framework will do the rest.

It is also possible to customize your authentication so that it uses your own login mechanism.

Cross-Platform

If you are building an application that is supposed to be accessible from different devices, then you need to consider cross-platform development.

With asp.net core, you are able to build web apps that are cross-platform and that can run on Windows, macOS, and Linux.

Mobile and AngularJS

If you want your application to be accessible through smartphones and tablets, then you need to use the mobile version of your application.

ASP.NET Core provides support for building native mobile applications.

AngularJS is a popular JavaScript framework that is often used with front-end applications. You can easily integrate AngularJS into asp.net core by using the AngularJS library.

You can also use the standard MVC views with AngularJS by rendering the views into a regular HTML page.

Database Access

You can create a database with asp.net core. And you can use SQLite, Microsoft SQL Server, and others.

You can also write LINQ queries against the databases.

You can also use Entity Framework or Dapper to interact with the database.

How to create a basic asp.net core project?

You can use Visual Studio 2019 to create asp.net core projects.

The first step is to create a new solution. The solution name can be anything, as long as you remember the folder structure. For example, if you want to create a Blazor project, you would have to create a folder named blazor.

The next step is to add a Web API project to the solution. You can call this project whatever you want, but as a guideline, we’ll name it api.

You can add the mvc, web forms, or razor templates to the project. To add the mvc template, you just need to click the Add menu, select Project > Add New Item, and then select Web Application.

Finally, you need to add a reference to the Microsoft.AspNetCore.App package.

Now you have everything set up. The next step is to build the project.

When you open the solution, you should see three files.

You can run the application by right-clicking the.sln file and selecting Run.

You can also run the application from the command line by running dotnet run.

ASP.NET Core uses dependency injection, so if you want to see how it works, you can run the application without the Startup class.

To run it from the command line, you just need to type dotnet run.

What to avoid in asp.net core?

While you are learning asp.net core, you should always try to avoid doing things that are not supported by the framework.

For example, you shouldn’t write code that interacts with the underlying file system directly. If you want to use a database, then you should use Entity Framework, and not something like SQLite.

You also don’t want to use the legacy asp.net web

 

Gulab Chand

About the author

Gulab Chand Tejwani is an independent consultant.He is a Project Management professional (PMP) and Microsoft Certified Trainer (MCT). He has more then 15 years of experience in Microsoft technologies like Aspnet,SharePoint,Sql server and Cloud Computing as well as in Big Data and Hadoop,Mobile App development.He has also worked as technical project manager..

>