Google News
logo
ASP.NET Interview Questions
ASP stands for Active Server Pages. It is also known as classic ASP. It is a server-side technology provided by Microsoft which is used to create dynamic and user-friendly web pages. It uses different scripting languages to create dynamic web pages which can be run on any browsers.
ASP.NET (Active Server Pages . NET) is a progressive new programming framework that empowers the rapid improvement of powerful web applications and administrations. It is a part of the Microsoft .NET Platform, it gives the simplest and most versatile approach to create, deploy and run web applications that can focus on any browser or device.ASP.NET is built on the CLR(Common Language Runtime) which allows the programmers to execute its code using any .NET language(C#, VB, etc.). It is specially designed to work with HTTP and for web developers to create dynamic web pages, web applications, websites, and web services as it provides a good integration of HTML, CSS, and JavaScript.
 
.NET Framework is used to create a variety of applications and services like Console, Web, and Windows, etc. But ASP.NET is only used to create web applications and web services. That’s why we termed ASP.NET as a subset of the .NET Framework.
ASP.MVC is a web application framework that is lightweight and has high testable features. ASP.NET supports 3 different types of components namely Model, View, and Controller.
 
Model : The Model component corresponds to all or any of the data-related logic that the user works with. This will represent either the info that’s being transferred between the View and Controller components or the other business logic-related data. For instance, a Customer object will retrieve the customer information from the database, manipulate it, and update its data back to the database or use it to render data.

View : The View component is employed for all the UI logic of the appliance. For instance, the Customer view will include all the UI components like text boxes, dropdowns, etc. that the ultimate user interacts with.

Controller : Controllers act as an interface between Model and consider components to process all the business logic and incoming requests, manipulate data using the Model component, and interact with the Views to render the ultimate output. For instance, the Customer controller will handle all the interactions and inputs from the Customer View and update the database using the Customer Model. An equivalent controller is going to be wont to view the Customer data.
Following are the core features that are provided by the ASP.NET Core
 
* Built-in supports for
 
* Built-in supports for the logging framework and it can be extensible
 
* Introduced a new, fast and cross-platform web server - Kestrel. So, a web application can run without IIS, Apache, and Nginx.
 
* Multiple hosting ways are supported
 
* It supports modularity, so the developer needs to include the module required by the application. However, the .NET Core framework is also providing the meta package that includes the libraries
 
* Command-line supports to creating, building, and running of the application
 
* There is no web.config file. We can store the custom configuration into an appsettings.json file
 
* There is no Global.asax file. We can now register and use the services in the startup class
 
* It has good support for asynchronous programming
 
* Support WebSocket and SignalR
 
* Provide protection against CSRF (Cross-Site Request Forgery)
Cross-Platform : The main advantage of ASP.NET Core is that it’s not tied to a Windows operating system, like the legacy ASP.NET framework. You can develop and run production-ready ASP.NET Core apps on Linux or a Mac. Choosing an open-source operating system like Linux results in significant cost-savings as you don’t have to pay for Windows licenses. 

High Performance : It’s also designed from scratch, keeping performance in mind. It’s now one of the fastest web application frameworks. 

Open Source : Finally, it’s open-source and actively contributed by thousands of developers all over the world. All the source code is hosted on GitHub for anyone to see, change and contribute back. It has resulted in significant goodwill and trust for Microsoft, notwithstanding the patches and bug-fixes and improvements added to the framework by contributors worldwide. 

New Technologies : With ASP.NET Core, you can develop applications using new technologies such as Razor Pages and Blazor, in addition to the traditional Model-View-Controller approach. 
ASP.NET has Server Controls features, Which provide facilities to manipulated values of the controls on the Server-Side. This is especially helpful while we want to create validating and dynamically web forms.
A configuration file (web.config) is utilized to oversee different settings that characterize a website. The settings are store in XML files that are independent of your application code. In this manner, you can configure settings freely from your code. This file stored inside the application root directory.

Web Server
IIS stands for Internet Information Services. It is created by Microsoft to provide Internet-based services to ASP.NET Web applications.
Following are the main usage of IIS :
 
* IIS is used to make your computer to work as a Web server and provides the functionality to develop and deploy Web applications on the server.
* IIS handles the request and response cycle on the Web server.
* IIS also offers the services of SMTP and FrontPage server extensions.
* The SMTP is used to send emails and use FrontPage server extensions to get the dynamic features of IIS, such as form handler.
ASP.Net is the next generation of ASP technology platform. It is superior to ASP in the following ways:
 
* Highly Scalable
* Compiled Code
* User Authentication
* Language Support
* Third party control
* Configuration and Deployment are easy.
* Object and Page caching
* Strict coding requirements
ASP.NET is an open-source web framework for building web applications on the .NET (dotNET) framework. It is made by Microsoft and variant 1.0 was delivered in 2002 to allow users to develop dynamic web applications, services, and sites. The framework is designed to work with the standard HTTP convention, which is the standard protocol utilized across all web-based applications.  ASP.NET is the replacement to the ASP (Active Server Pages) innovation and was a significant update as far as adaptability and power. It is an expansion of the .NET framework with extra tools and libraries for building things on the web, including web applications and websites.  The ASP.NET cross-plate form version is known as ASP.NET Core, which was delivered in 2016. ASP.NET is still updated and supported.
There are mainly four different types of  Server-side controls in ASP.NET :
 
* HTML server controls
* Web Server controls
* User controls
* Validation controls
A PostBack is the process of presenting an ASP.NET page to the server for processing. PostBack is done if certain credentials of the page are to be checked against certain sources, (for example, confirmation of username and secret key/password using a database). This is something that a client machine can not able to achieve and subsequently, these details must be ‘posted back’ on the server. So we can say that a postback event occurs on the client-side but is handled by the code in a copy of the page running on the server.
There is some key difference between Web.config and Machine.config file below :
 
The machine.config record is the master configuration document on your framework with a lot of default settings.And Web.config is the file for the local settings to be applied for a website which store configuration information in XML format.

The settings of Machine.config file are applied to the entire asp.net applications on your server while the settings made in the Web.config file are applied to that specific web application only.

Each .NET Framework form has only one machine.config file, simultaneously, each web application has its own web.config file. Directories inside a web application can have web.config files as well.

The machine.config is shared values among numerous applications on the server, while Web.config documents contain application explicit things, for example, database connection strings.

Suppose if you want any improvements in the web.config, then the web application will promptly load the changes but in the machine.config case you should restart the application.

The machine.config document will automatically introduce when you install Visual Studio.Net and it resides in the c:\windows\microsoft.net\framework\version\config folder whereas web.config will automatically be made when you make an ASP.Net web application project.

Machine.config is the design configuration file for all the applications in the IIS, but Web. config is a configuration file for a specific application.
The framework .NET Core 2.0 introduced Metapackage which includes all the supported packages by ASP.NET code with their dependencies into one package. It helps us to do fast development as we don't require to include the individual ASP.NET Core packages. The assembly Microsoft.AspNetCore.All is a meta package provided by ASP.NET core.
The startup class is the entry point of the ASP.NET Core application. Every .NET Core application must have this class. This class contains the application configuration related items. It is not necessary that the class name must be "Startup", it can be anything, we can configure the startup class in the Program class.
 public class Program
 {
 public static void Main(string[] args)
 {
 CreateWebHostBuilder(args).Build().Run();
 }
 
 public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
 WebHost.CreateDefaultBuilder(args)
 .UseStartup<TestClass>();
 }
ASP.NET validation controls define an important role in validating the user input data. Whenever the user gives the input, it must always be validated before sending it across to various layers of an application. If we get the user input with validation, then chances are that we are sending the wrong data. So, validation is a good idea to do whenever we are taking input from the user. There are the following two types of validation in ASP.NET,
 
* Client-Side Validation
* Server-Side Validation

Client-Side Validation
When validation is done on the client browser, then it is known as Client-Side Validation. We use JavaScript to do the Client-Side Validation. Server-Side Validation When validation occurs on the server, then it is known as Server-Side Validation. Server-Side Validation is a secure form of validation. The main advantage of Server-Side Validation is if the user somehow bypasses the Client-Side Validation, we can still catch the problem on server-side. The following are the Validation Controls in ASP.NET,
 
* RequiredFieldValidator Control
* CompareValidator Control
* RangeValidator Control
* RegularExpressionValidator Control
* CustomFieldValidator Control
* ValidationSummary
View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.
 
A web application is stateless. That means that a new instance of a page is created every time when we make a request to the server to get the page and after the round trip our page has been lost immediately
 
Features of View State These are the main features of view state,
 
* Retains the value of the Control after post-back without using a session.
* Stores the value of Pages and Control Properties defined in the page.
* Creates a custom View State Provider that lets you store View State Information in a SQL Server Database or in another data store.

Advantages of View State
 
* Easy to Implement.
* No server resources are required: The View State is contained in a structure within the page load.
* Enhanced security features: It can be encoded and compressed or Unicode implementation.
State Management in ASP.NET
 
* A new instance of the Web page class is created each time the page is posted to the server.
* In traditional Web programming, all information that is associated with the page, along with the controls on the page, would be lost with each roundtrip.
* The Microsoft ASP.NET framework includes several options to help you preserve data on both a per-page basis and an application-wide basis. These options can be broadly divided into the following two categories,  

* Client-Side State Management Options
* Server-Side State Management Options

Client-Side State Management
 
* Client-based options involve storing information either in the page or on the client computer.
* Some client-based state management options are,  
* Hidden fields
* View state
* Cookies
* Query strings

Server-Side State Management
 
* There are situations where you need to store the state information on the server side.
* Server-side state management enables you to manage application-related and session-related information on the server.
* ASP.NET provides the following options to manage state at the server side:  
* Application state
* Session state
State Management
* View Result
* Javascript Result
* Redirect Result
* JSON Result
* Content Result
We can maintain sessions in MVC using three different ways :
 
* Temp data
* Viewdata
* View bag
Grid View, DataGrid
It was introduced with Asp.Net 2.0. It was introduced with Asp.Net 1.0.
Built-in supports for Paging and Sorting. For sorting you need to handle SortCommand event and rebind grid required and for paging, you need to handle the PageIndexChanged event and rebind grid required.,
Built-in supports for Update and Delete operations. Need to write code for implementing Update and Delete operations.
Supports auto-format or style features. This feature is not supported.
Performance is slow as compared to DataGrid Performance is fast as compared to GridView.
User Control Custom Control
User controls are created just like a web form. They make use of the existing controls to define their own logic. A custom control is one that is made or created by the programmer to serve the business needs, by extending the functionality of existing controls.
We can User control easily. The creation of custom control is not easy as compare to user control
These control do not run on their own dll. While these control can run on their own dl.
We can not add to the toolbox. While we can add to the toolbox.we
This control is not flexible. This control is more flexible.
Once we created a single copy of this control, we can use this copy to different projects as well. We can not call or use a single copy of this control in different applications. For this, we need to create a control for each and every application.
Repeater ListView
Flexible layout introduced in .NET 1.0. Flexible layout with easy customization introduced with .NET 3.5
No built-in support, custom code should be written for data grouping and paging. Provides built-in support for data grouping and paging.
Update, insert, delete and sorting operations are not supported. All the operations are supported.
Offers better performance. Slower performance compared to a repeater.
Local Resources Global Resources
A local resource can only be accessed by the page that created it. Accessible by all pages.
Difficult to maintain when the website has a lot of localized content as each page requires a resource file for each language. Only one file per language is required.
Stored in the App_LocalResources folder. Stored in the App_GlobalResources folder.
Server controls are the primary controls in ASP.NET and are categorized in the following groups:
 
Validation controls :  These controls validate user input by running the client-side script

Data source controls :  These are used to provide data binding for multiple data sources.

Data view controls :  These controls are used to view/display list and table data that is obtained from data sources

Login and security controls :  used for user authentication

Master pages :  used for giving a consistent interface and layout for the whole application

Rich controls :  These are used to implement special features like fileupload, calendar control, AdRotator etc.

Navigation controls :   help in navigation through menus, tree views and so on

Personalization controls :   used for personalization of page based on user information and preferences
Web server controls are powerful than HTML server-side controls. The only difference is that they must have the runat = "server" attribute set. This attribute makes the control available for server-side programming. Each ASP.NET Server Control is capable of exposing an object model containing properties, methods, and events. This object model can be utilized by the ASP.NET developers to modify and interact with the Web page. Web controls contain all basic controls of HTML controls as well as some new controls like as DataGrid, DataList, and Calendar.

WEB CONTROL DESCRIPTION
Label Represents a label control
ListBox Represents a list box control
CheckBox Represents a Check box control
Calendar Represents a calendar control
ImageButton Represents an image button control
TableCell Represents a table cell
Panel Represents a panel control
DataList Represents a data list control
TextBox Represents a text box control
Image Represents an image control
CheckBoxList Represents a list box with checkboxes
Button Represents a button control
HyperLink Represents a hyperlink control
TableRow Represents a row of a table
RadioButtonList Represents a list box with radio button controls
DataGrid Represents a data grid control
DropDownList Represents a drop-down list control
AdRotator Represents an ad rotator control
RadioButton Represents a radio button control
LinkButton Represents a link button control
Table Represents a table control
Repeater Represents a repeater control
The ASP.NET supports a robust login controls for web-based application which does not require any program coding. These login controls coordinate with ASP.NET participation and forms authentication to help automated client verification for a server webpage. By default, the ASP.NET login controls work in plain text over HTTP. The ASP.NET supports different types of Login Controls like:
 
* Login Control
* LoginView Control
* LoginStatus Control
* LoginName Control
* PasswordRecovery Control
* CreateUserWizard Control
* ChangePassword Control
Cookies are a State Management Technique that can store the values of control after a post-back. Cookies can store user-specific information on the client's machine, such as when the user last visited your site. Cookies are also known by many names, such as https Cookies, Browser Cookies, Web Cookies, Session Cookies and so on. Basically cookies are a small text file sent by the web server and saved by the Web Browser on the client's machine. List of properties containing the httpsCookies Class,
 
* Domain : Using these properties we can set the domain of the cookie.

* Expires : This property sets the Expiration time of the cookies.

* HasKeys : If the cookies have a subkey then it returns True.

* Name : Contains the name of the Key.

* Path : Contains the Virtual Path to be submitted with the Cookies.

* Secured : If the cookies are to be passed in a secure connection then it only returns True.

* Value : Contains the value of the cookies.

Limitation of the Cookies
 
The size of cookies is limited to 4096 bytes.
A total of 20 cookies can be used in a single website.
Ajax stands for Asynchronous JavaScript and XML; in other words Ajax is the combination of various technologies such as a JavaScript, CSS, XHTML, DOM, etc. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the entire page. We can also define Ajax is a combination of client-side technologies that provides asynchronous communication between the user interface and the web server so that partial page rendering occurs instead of a complete page postback. Ajax is platform-independent; in other words, AJAX is a cross-platform technology that can be used on any Operating System since it is based on XML & JavaScript. It also supports open source implementation of other technology. It partially renders the page to the server instead of the complete page being post back. We use AJAX for developing faster, better and more interactive web applications. AJAX uses an https request between web server & browser.
 
* With AJAX, when a user clicks a button, you can use JavaScript and DHTML to immediately update the UI, and spawn an asynchronous request to the server to fetch results.

* When the response is generated, you can then use JavaScript and CSS to update your UI accordingly without refreshing the entire page. While this is happening, the form on the user's screen doesn't flash, blink, disappear, or stall.

* The power of AJAX lies in its ability to communicate with the server asynchronously, using a XMLhttpsRequest object without requiring a browser refresh.

* Ajax essentially puts JavaScript technology and the XMLhttpsRequest object between your Web form and the server.
ASP.NET introduces the concept of an Application Domain which is known as AppDomain for short. It can be considered as a lightweight process which is both a container and boundary. The .NET runtime uses an AppDomain as a container for code and data, just like the operating system uses a process as a container for code and data. As the operating system uses a process to isolate misbehaving code, the .NET runtime uses an AppDomain to isolate code inside a secure boundary. The CLR can allow the multiple .NET applications to run in a single AppDomain. Mulitple Appdomains can exist in Win32 process.
 
How to create AppDomain
 
AppDomains are created using the CreateDomain method. AppDomain instances are used to load and execute assemblies (Assembly). When an AppDomain is no longer in use, it can be unloaded.
public class MyAppDomain: MarshalByRefObject
{
    public string GetInfo()
    {
        return AppDomain.CurrentDomain.FriendlyName;
    }
}
public class MyApp
{
    public static void Main()
    {
        AppDomain apd = AppDomain.CreateDomain("Rajendrs Domain");
        MyAppDomain apdinfo = (MyAppDomain) apd.CreateInstanceAndUnwrap(Assembly.GetCallingAssembly(
    )
            .GetName()
            .Name, "MyAppDomain");
        Console.WriteLine("Application Name = " + apdinfo.GetInfo());
    }
}
A QueryString is a collection of characters input to a computer or web browser. A Query String is helpful when we want to transfer a value from one page to another. When we need to pass content between the HTML pages or aspx Web Forms in the context of ASP.NET, a Query String is Easy to use and the Query String follows a separating character, usually a Question Mark (?). It is basically used for identifying data appearing after this separating symbol. A Query String Collection is used to retrieve the variable values in the https query string. If we want to transfer a large amount of data then we can't use the Request.QueryString. Query Strings are also generated by form submission or can be used by a user typing a query into the address bar of the browsers. Syntax of Query String Request.QueryString(variable)[(index).count]

Query string
Advantages
* Simple to Implement
* Easy to get information from Query string.
* Used to send or read cross domain (from different domain).

Disadvantages
* Human Readable
* Client browser limit on URL length
* Cross paging functionality makes it redundant
* Easily modified by end user
At the point when server-side processing is included, then there are four stages included :  
 
* A user requests a Web form from the Web server.
* Web Server reacts back with the mentioned Web form.
* The user enters the information and submits the webform to the webserver.
* Then Web Server processes the form structure and sends the outcomes back to the particular user.

Now, stage 3 is known as a page postback, while stages 3 and 4 are aggregately known as a “roundtrip”. We can say that- A roundtrip includes making a total excursion over the network to the Web browser and getting the reaction back.  The Web applications use HTTP to build up correspondence between the Web program and the Web server. 
In ASP.NET, Razor provides the syntax for developing dynamic web pages with the help of C# and HTML. ASP.NET can be integrated with JS(JavaScript) and it also includes the frameworks like React and Angular for the SPA(Single Page Application.)
REST stands for REpresentational State Transfer.REST is an architectural style that doesn’t follow any strict standard but follows six constraints defined by Roy Fielding in 2000. Those constraints are – Uniform Interface, Client-Server, Stateless, Cacheable, Layered System, Code on Demand.REST is not restricted to XML and it’s the choice of implementer which Media-Type to use like XML, JSON, Plain-text. Moreover, REST can use SOAP protocol but SOAP cannot use REST.REST is easy to implement and requires less bandwidth such as smartphones.
 
Architectural Constraints of RESTful API : There are six architectural constraints that make any web service are listed below:
 
* Uniform Interface
* Stateless
* Cacheable
* Client-Server
* Layered System
* Code on Demand
The Finalize technique is utilized to perform a cleanup procedure on unmanaged resources held by the current object before the object is destroyed. The strategy is ensured and subsequently is available just through this class or through a derived class.
* Page request
* Starting of page life cycle
* Page initialization
* Page Load
* Validation
* Postback event handling
* Page rendering
* Unload
A web application is a piece of software that can be accessed by the browser. A Browser is an application that is used to browse the internet. Web application needs authentication. The web application uses a combination of server-side scripts and client-side scripts to present information. It requires a server to manage requests from the users. For example, Google Apps
 
A website is a collection of related web pages that contains images, text, audio, video, etc. It can be consist of one page, two pages, and n number of pages. A website provides visual and text content that users can view and read. To view a website requires a browser(chrome, firefox). There are many types of websites like Archive website, Blog, Community website, Dating website, etc. For example, Amazon, youtube, etc.
Assert() – Checks for a condition, and displays a message if the condition is false.

Close() –
Cleanup the output buffer, and then closes the Listeners so that they no longer receive debugging output.

Fail() –
This method emits an error message.

GetType() –
It is used for “Gets the Type of the Object”.

ToString() –
Returns a String that represents the current Object

GetHashCode() –
This method works like a hash function for a particular type. It is suitable for use in hashing algorithms and data structures like a hash table.

Equals() –
Determines whether the specified Object is the same instance as the current Object

Warn() –
Writes trace information, along with optional exception data, to the trace log. All warnings appear as red text. It has two forms. The first form writes trace information to the trace log including any user-defined categories.

Write() –
Writes trace information to the trace log. It has two forms. The first form writes trace information to the trace log, including any user-defined categories and traces messages.
* PreInit
* Init
* InitComplete
* LoadViewState
* LoadPostData
* PreLoad
* Load
* LoadComplete
* PreRender
* PreRenderComplete
* SaveStageComplete
* UnLoad
Navigation Control is defined as a menu that can be stored in a file to make it easier to maintain. This file is normally called web.Sitemap, and is stored in the root directory of the web. An ASP.NET has three different types of Navigation control:
 
* Dynamic Menus
* TreeView
* Site Map path
The  TreeView control is made up of nodes. Each entry in the tree is called a node and is represented by a TreeNode object. A node that contains other nodes is called a parent node. A node that is contained by another node is called a child node. A node that has no child nodes is called a leaf node. A node that is not contained by any other node but is the ancestor to all the other nodes in the root node. A node can be both a parent and a child, but root, parent, and leaf nodes are mutually exclusive. Several visual and behavioral properties of nodes are determined by whether a node is a root, parent, or leaf node.
The project file is one of the most important files in our application. It tells .NET how to build the project.
 
All .NET projects list their dependencies in the .csproj file. If you have worked with JavaScript before, think of it like a package.json file. The difference is, instead of a JSON, this is an XML file.
 
When you run dotnet restore, it uses the .csproj file to figure out which NuGet packages to download and copy to the project folder (check out the next question to learn more about Nuget).
 
The .csproj file also contains all the information that .NET tooling needs to build the project. It includes the type of project you are building (console, web, desktop, etc.), the platform this project targets, and any dependencies on other projects or 3rd party libraries.
 
Here is an example of a .csproj file that lists the Nuget packages and their specific versions. 
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
  <TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="AWSSDK.S3" Version="3.5.6.5" />
  <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.1" />
  <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
  <PackageReference Include="Npgsql" Version="5.0.1.1" />
  <PackageReference Include="Serilog" Version="2.10.0" />
</ItemGroup>
</Project>
In the above example, 
 
* The SDK attribute specifies the type of .NET project.
* TargetFramework is the framework this application will run on, .NET 5 in this case.
* The PackageReference element includes the NuGet packages. The Version attribute specifies a version of the package we want.
Software developers don’t write all code from scratch. They rely on libraries of code written by other developers. Any modern development platform must provide a mechanism where developers can download and use existing libraries, often called packages. For example, the JavaScript ecosystem has NPM (Node Package Manager), where developers can find and use libraries written by other JavaScript developers.
 
NuGet is a package manager for the .NET ecosystem. Microsoft developed it to provide access to thousands of packages written by .NET developers. You can also use it to share the code you wrote with others.
 
A typical web application developed using ASP.NET relies on many open source NuGet packages to function. For example, Newtonsoft.Json is a very popular package (with 91,528,205 downloads at the time of writing) used to work with JSON data in .NET. 
Program.cs class is the entry point of our application. An ASP.NET application starts in the same way as a console application, from a static void Main() function.
 
This class configures the web host that will serve the requests. The host is responsible for application startup and lifetime management, including graceful shutdown.
 
At a minimum, the host configures a server and a request processing pipeline. The host can also set up logging, configuration, and dependency injection.
This class handles two important aspects of your application, namely service registration, and middleware pipeline.
 
Services are C# classes that your application depends on for providing additional functionality, both used by the framework and your application. Examples include logging, database, etc. These services must be registered to be instantiated when your app is running and when it needs them.
 
The middleware pipeline is the sequence in which your application processes an HTTP request (the next question explains the concept of Middleware in detail).
 
Startup class contains two methods : ConfigureServices() and Configure(). As the name suggests, the first method registers all the services that the application needs. The second method configures the middleware pipeline.
The wwwroot folder contains static files and compiled assets, such as JavaScript, CSS, and images that your web application needs. Wwwroot is the only folder in the entire project that's exposed as-is to the browser. 
Appsettings.json contains all of the application's settings, which allow you to configure your application behavior.
 
Here is an example of an appsettings.json file.
{
 "Logging": {
     "LogLevel": {
          "Default": "Information",
    "Microsoft": "Warning",
    "Microsoft.Hosting.Lifetime": "Information"
      }
  },
"ConnectionStrings": {
    "AppConnection": ""
},
"AWS": {
  "Profile": "local-test-profile",
  "Region": "us-west-2"
},
"AllowedHosts": "*"
}
Controllers and views need to work with data that comes from HTTP requests. For example, routes may provide a key that identifies a record, and posted form fields may provide model properties. The process of converting these string values to .NET objects could be complicated and something that you have to do with each request. Model binding automates and simplifies this process. 
 
The model binding system fetches the data from multiple sources such as form fields, route data, and query strings. It also provides the data to controllers and views in method parameters and properties, converting plain string data to .NET objects and types in the process.
 
Example :
Let’s say you have the following action method on the PostsController class:
[HttpGet("posts/{id}")]
public ActionResult<Post> GetById(int id, bool archivedOnly)
And the app receives a request with this URL:
http://yourapp.com/api/Posts/5?ArchivedOnly=true
After the routing selects the action method, model binding executes the following steps.
 
* Locate the first parameter of GetByID, an integer named id, look through the available sources in the HTTP request and find id = "5" in route data.
* Convert the string "5" into an integer 5.
* Find the next parameter of GetByID, a boolean named archivedOnly.
* Look through the sources and find "ArchivedOnly=true" in the query string. It ignores the case when matching the parameters to the strings.
* Convert the string "true" into boolean true.

Some other examples of attributes include :
1. [FromQuery] - Gets values from the query string.
2. [FromRoute] - Gets values from route data.
3. [FromForm] - Gets values from posted form fields.
4. [FromBody] - Gets values from the request body.
5. [FromHeader] - Gets values from HTTP headers.
ASP.NET Core has many different types of IActionResult:
 
ViewResult : Generates an HTML view.

RedirectResult : Sends a 302 HTTP redirect response to send a user to a specified URL automatically.

RedirectToRouteResult : Sends a 302 HTTP redirect response to automatically send a user to another page, where the URL is defined using routing.
FileResult : Returns a file as the response.

ContentResult : Returns a provided string as the response.

StatusCodeResult : Sends a raw HTTP status code as the response, optionally with associated response body content.

NotFoundResult : Sends a raw 404 HTTP status code as the response.
HTTPContext encapsulates all HTTP - specific information about an individual HTTP request. You can access this object in controllers by using the ControllerBase.HttpContext property:
public class HomeController : Controller
{
  public IActionResult About()
  {
      var pathBase = HttpContext.Request.PathBase;

      ...

      return View();
  }
}
As the name suggests, conventional routing uses predefined conventions to match the incoming HTTP request to a controller’s action method. It handles the most general cases that a typical web application needs, but you can modify it to suit your specific needs.
 
For example, the Configure() method in the Startup.cs class contains the following code that sets up the conventional routing.
app.UseEndpoints(endpoints =>
{
  endpoints.MapControllerRoute(
      name: "default",
      pattern: "{controller=Home}/{action=Index}/{id?}");
});
This code creates a single route named ‘default’. The route template pattern ‘{controller=Home}/{action=Index}/{id?}’ is used to match an incoming URL such as /Posts/Archived/5 to the Archived(int id) action method on the PostsController, passing 5 for the id parameter. By default, the router uses the Index method on the HomeController. 
Attribute routing is an alternative routing strategy for conventional routing. It is often used to create REST API endpoints for web services. It uses a set of attributes to map action methods directly to route templates.
 
Attribute routing directly defines the routes on action methods. We can also use these attributes on the controllers. It enables us to get fine-grained control over what routes map to which actions. With attribute routing, the controller and action names play no part in determining the action method.
 
For example, we use attributes Blog and Home to map an incoming URL such as myapp.com/blog/post/3 to the Show method on the PostsController.
[Route("blog")]
public class PostsController : Controller
{
  [HttpGet("post/{id:int}")]
  public IActionResult Show(int id = 0)
  {
      Post post = new Post()
      {
          ID = id
      };

      return View("Show", post);
  }

  [HttpGet("edit/{id:int}")]
  public IActionResult Edit(int id)
  {
      Post postToEdit = _service.Get(id);

      return View("Edit", postToEdit);
  }
}
In the above example, the attribute [Route(“blog”)] is placed on the controller, whereas the route [HttpGet(“post/{id:int}”)] is placed on the action method. A controller route applies to all actions in that controller. For example, the second [“edit/{id:int}”] route matches the url myapp.com/blog/edit/3.
 
In addition to the above route templates, ASP.NET Core provides the following HTTP verb templates.
 
* [HttpGet]
* [HttpPost]
* [HttpPut]
* [HttpDelete]
* [HttpHead]
* [HttpPatch]
The checkbox is used to get multiple inputs from the user. Users can select more than one choice from the given options. In the code, it is set as a yes/no or true/false option, when it is ticked, the value of the checkbox is true, else false.  
HTML server controls provide automatic state and server-side event management. These are HTML elements that have the attribute runat=server. The HTML server control properties and output are the same as their equivalent HTML tags. These controls are compiled when the ASP.NET application is compiled.
The difference between session and application object is that all users share one Application object and with sessions, there is one session object for each user. Data stored in the application object can be shared by all the sessions of the application.

Application object stores data in the key-value pair. Session object stores session-specific information and the information are visible within the session only. ASP.NET creates unique SessionId for each session of the application.

SessionIDs are maintained either by an HTTP cookie or a modified URL, as set in the applications configuration settings. By default, SessionID values are stored in cookies.
here are three types of authentication available in ASP.NET :
 
Windows Authentication : This authentication method uses built-in Windows security features to authenticate a user.

Forms Authentication : Authenticates against a customized list of users or users in a database.

Passport Authentication : Validates against Microsoft Passport service which is basically a centralized authentication service.
Both Response.Redirect and Server.Transfer methods are used to transfer a user from one web page to another web page. Both methods are used for the same purpose but still there are some differences as follows. The Response.Redirect method redirects a request to a new URL and specifies the new URL while the Server.Transfer method for the current request, terminates execution of the current page and starts execution of a new page using the specified URL path of the page. Both Response.Redirect and Server.Transfer has same syntax like:
Response.Redirect("UserDetail.aspx");
Server.Transfer("UserDetail.aspx");
Before touching on more points I want to explain some https status codes, these are important for the understanding of the basic differences between these two. The https status codes are the codes that the Web server uses to communicate with the Web browser or user agent.

Server.Transfer and Response.redirect
By default a session uses a cookie in the background. To enable a cookie-less session, we need to change some configuration in the Web.Config file. Follow these steps,
 
* Open Web.Config file.
* Add a <sessionState> tag under <system.web> tag.
* Add an attribute "cookieless" in the <sessionState> tag and set its value to "AutoDetect" like below:
<sessionState cookieless="AutoDetect" regenerateExpiredSessionId="true"/>​

 

The possible values for "cookieless" attribute are,
 
AutoDetect : Session uses background cookie if cookies are enabled. If cookies are disabled, then the URL is used to store session information.
UseCookie : Session always use background cookie. This is default.
UseDeviceProfile : Session uses background cookie if browser supports cookies else URL is used.
UseUri : Session always use URL.

"regenerateExpiredSessionId" is used to ensure that if a cookieless url is expired a new new url is created with a new session. And if the same cookieless url is being used by multiple users an the same time, they all get a new regenerated session url. For further info click on the link,