Friday, May 5, 2023

What's the difference between .NET Core Framework and .NET Standard?

► .Net Standard is a specification for implementing the Base Class Library (BCL). BCL contains classes such as exception handling, XML, collections, I/O and networking. WPF, WCF and ASP.NET do not form part of BCL and so are not included in .NET Standard library.

► .NET Core is a managed framework that builds desktop and web applications in cross-platform.

► Both ".NET Core" and ".NET Framework" include .NET Standard for BCL in their managed framework.

.NET Framework is a framework that builds desktop and web applications in Windows only. It is highly dependent on the architecture.

What is middleware?

► A middleware is nothing but a component (class) which is executed on every request in ASP.NET Core application.

► It is software which is injected into the application pipeline to handle request and responses.

► Middleware component is program that's build into an app's pipeline to handle the request and response.

► Each middleware component can decide whether to pass the request to next component and to perform any operation before or after next component in pipeline.

What is wwwroot folder in ASP.NET Core?

► By default the wwwroot is the root folder that contains the static files such as HTML, CSS and Javascript.

►The files can be stored here and accessed with a relative path to the root.

► Only these files inside the wwwroot can be served over HTTP Requests. All other files are filtered out and cannot be served by default.

What is the role of ConfigureServices and Configure method?

► ConfigureServices method is optional and defined inside startup class.

► It takes care of registering services that are consumed across the application using Dependency Injection (DI) or Application Services.

► It's get called by host before 'Configure' method to configure the app's services.

►  Configure method is used to add middleware components to IApplication Builder instance that's available in Configure method.

► It accepts IApplication Builder as a parameter and also it has two optional parameters: IHostingEnvironment and ILoggerFactory.

► Using this method, we can configure built-in middleware such as routing, authentication, session, etc. as well as third-party middleware.

► Configure method also specify how the app respond to HTTP request and response.

Where is startup class in ASP.NET Core?

ASP.NET Core apps use a Startup class, which is named Startup by convention. The Startup class: Optionally includes a ConfigureServices method to configure the app's services. A service is a reusable component that provides app functionality.

What is dependency injection in MVC?

The Dependency Injection pattern is a particular implementation of Inversion of Control. Inversion of Control (IoC) means that objects do not create other objects on which they rely to do their work. Instead, they get the objects that they need from an outside source (for example, an xml configuration file).

Dependency Injection (DI) means that this is done without the object intervention, usually by a framework component that passes constructor parameters and set properties.

Thursday, May 4, 2023

what are the feature provided by .net core?

 ASP.NET Core MVC provides features to build web APIs and web apps:

1.The Model-View-Controller (MVC) pattern helps make your web APIs and web apps testable.

2.Razor Pages is a page-based programming model that makes building web UI easier and more productive.

3.Razor markup provides a productive syntax for Razor Pages and MVC views.

4.Tag Helpers enable server-side code to participate in creating and rendering HTML elements in Razor files.

5.Built-in support for multiple data formats and content negotiation lets your web APIs reach a broad range of clients, including browsers and mobile devices.

6.Model binding automatically maps data from HTTP requests to action method parameters.

7. Model validation automatically performs client-side and server-side validation.

What is .NET Core used for?

 ASP.NET Core is a cross-platform, high-performance, open-source framework for building modern, cloud-enabled, Internet-connected apps. With ASP.NET Core, you can: Build web apps and services, Internet of Things (IoT) apps, and mobile backends.

DCL commands

DCL COMMANDS:

1. GRANT:

It is used to give user access privileges to a database.

Syntax:

GRANT SELECT, UPDATE ON MY TABLE TO SOME_USER, ANOTHER_USER;

2. REVOKE:

GRANT SELECT, UPDATE ON MY TABLE TO SOME USER< ANOTHER_USER;

Syntax:

REVOKE SELECT, UPDATE ON MY TABLE FROM USER!, USER2;

TCL commands

TCL COMMANDS:

1. COMMIT:

Commits a Transaction. The COMMIT command saves all the transactions to the database since the last COMMIT or ROLLBACK command.

Syntax: COMMIT;

Example:

DELETE FROM Student WHERE AGE = 21; COMMIT:

2. ROLLBACK:

If any error occurs with any of the SQL-grouped statements, all changes need to be aborted. The process of reversing changes is called rollback

Syntax: ROLLBACK;

Example:

DELETE FROM Student WHERE AGE = 21; ROLLBACK;