Posts

Showing posts with the label BSc CSIT 6th Semester

Define Asynchronous programming techniques with examples of async/ wait functions.

 Asynchronous programming techniques Asynchronous programming in C# is an efficient approach towards activities blocked or access is delayed. If an activity is blocked in a synchronous then, the complete application waits and it takes more time. By using the asynchronous approach the applications continue with other ' tasks as well.' The async and await keywords in C# are used in async programming. Using them, we can work with .Net resources, .Net Core, etc. Example: using System; using System. Threading. Tasks; namespace My Console App {  Class Async Await Test  {  Static void Main (string [ ]args) {  Method1();  Method 2();  Console. ReadKey (); public static async Task Method1() {  await Task.Run(() =>  {  for(int & i= 0; i ≤ 100; i++)  Console Write Line ("Methed 1"); } }); }  public static void Method 2  {  for (int i=0; i <25, i++) { Console.WriteLine (Method 2");  } } } }

Explain different types of LINQ with examples.

Image
 LINQ (Language Integrated Query)   LINQ (Language Integrated Query) is the name for a set of technologies based on the integration of query capabilities directly into the C# language.  With  LINQ, a query is a first-class language construct just like classes, methods, events. The LINQ family of technologies provides a consistent query expression experience for objects (LINQ to Objects), relational database CLING to SQL) and XML (LINQ to XML). Example class LINQQuery Expressions {  //Specify data source  static void Main () int[] score s = new int[ ] {10, 20, 30, 40}; // Define query expression Enumercable <int>scoredQuery=from score in scores where score > 20 select score; //Execuite query for each (inti in scoreQuery) { console.Write(i+" "); } } } Output 30.40 a) Introduction of LINQ to XML While using LINQ to XML, loading XML documents into memory is easy and more easier to querying and document modifications. It is also possible to save XML documents existing in

Explain Abstract Class.

Image
 Abstract Class Classes can be declared as abstract by using the keyword abstract. Abstract classes are one of the essential behaviors provided by. NET. If you like to take classes that only represent base classes, and don’t want anyone to create objects of these class types, use an abstract class to implement such functionality. Objects of this class can be instantiated but can make derivations of this. The derived class should implement the abstract class members.

Explain PARTIAL CLASS.

 PARTIAL CLASS  It is possible to split the definition of a class, a struct, an interface or a method over two or mon source files. Each source file contains a section of the type or method definition, and all parts a combined when the application is compiled. When working on large projects, spreading a class over separate files enables multiple programmers to work on it at the same time. When working with an automatically generated source, code can be added to the class without having to recreate the source file. Visual Studi uses this approach when it creates Windows Forms, Web service wrapper code, and so on. To split a class definition, use the partial keyword modifier, as shown here:  public partial class Coords { private int x; private int y; public Coords (int x, int y) { this.x = x; this.y = y; } public partial class Coords { public void Print Coords() { Console.WriteLine("Coords: (0), (1)", x, y); } class TestCoords { static void Main()  { Coords myCoords new Coords(

Explain different Collection Types.

 Collection Types • Collection Types are specialized classes for data storage and retrieval. • These classes provide support for stacks, queues, lists, and hash tables. • Collection classes serve various purposes, such as allocating memory dynamically to elements and accessing a list of items on the basis of an index, etc. • Namespaces: a) System.Collection b) System.Collection.Generic a) System.Collection • ArrayList, Hashtable, Sorted List, Stack, Queue Exampe of Array List - System.Collections Arraylist al = new ArrayList(); al.Add(1); al.Add("Hari"); al.Add(3.4); Console.WriteLine (al.Count); al. Remove (3.4); al. RemoveAt (0); Console.WriteLine(al. Count); b)System.Collection.Generic • generic collection is strongly typed (type-safe), that you can only put one type of object into it. • This eliminates type mismatches at runtime. • Another benefit of type safety is that performance is better Ex: List, Dictionary Example of List - System.Collection.Generic List<string&g

Short note on Collection .

 Collection  - For many applications, you want to create and manage groups of related objects. There are two ways to group objects: by creating arrays of objects, and by creating collections of objects Arrays are most useful for creating and working with a fixed number of strongly typed objects.  - Collections provide a more flexible way to work with groups of objects. Unlike arrays, the group of objects you work with can grow and shrink dynamically as the needs of the application change. For some collections, you can assign a key to any object that you put into the collection so that you can quickly retrieve the object by using the key. - A collection is a class, so you must declare an instance of the class before you can add an element to that collection. Example  using System; using System.Collections; namespace CollectionApplication { class Program { static void Main(string[] args) { ArrayList al = new ArrayList(); Console.WriteLine("Adding some numbers:"); al.Add(45); al

how to register Application Service with built-in IOC container and use it in our application.

Registering Application Service  In order to let the IoC container automatically inject our application services, we first need to register them with an IOC container. Consider the following example of a simple ILog interface and its implementation class. We will see how to register it with a built-in IoC container and use it in our application. public interface ILog { void info(string str); } class MyConsoleLogger : ILog { public void info(string str) { Console.WriteLine(str); } } ASP.NET Core allows us to register our application services with IoC container, in the ConfigureServices method of the Startup class. The ConfigureServices method includes a parameter of IServiceCollection type which is used to register application services. Let's register above ILog with IoC container in ConfigureServices() method asshown below.  Example: Register Service public class Startup { public void ConfigureServices(IServiceCollection services) { services.Add(new ServiceDescriptor(typeof(ILog),

Explain Rendering HTML with Views.

 Rendering HTML with Views In the MVC pattern, the view handles the app's data presentation and user interaction. A view is an HTML template with embedded Razor markup. Razor markup is code that interacts with HTML markup to produce a webpage that's sent to the client. In ASP.NET Core MVC, views are .cshtml files that use the C# programming language in Razor markup. Usually, view files are grouped into folders named for each of the app's controllers. The folders are stored in a Views folder at the root of the app   The Home controller is represented by a Home folder inside the Views folder. The Home folder contains the views for the About, Contact, and Index (homepage) webpages. When a user requests one of these three web pages, controller actions in the Home controller determine which of the three views is used to build and return a webpage to the user. Use layouts to provide consistent webpage sections and reduce code repetition. Layouts often contain the header, navigati

Short note on Controllers Responsibilities.

 Controllers Responsibilities  Controllers are usually placed in a folder called "Controllers", directly in the root of your MVC project.  They are usually named based on their purpose, with the word "Controller" as a suffix.  The Controller has three major responsibilities ◦ Handle the Request from the User ◦ Build a Model – Controller Action method executes the application logic and builds a model ◦ Send the Response – it returns the Result in HTML/File/JSON/XML or other formats as requested by the user.

Explain MVC(Model – View - Controller) Design Pattern.

 MVC(Model – View - Controller) Design Pattern  The MVC design has actually been around for a few decades, and it's been used across many different technologies. The MVC design pattern is a popular design pattern for the user interface layer of a software application. In larger applications, you typically combine a model-view-controller UI layer with other design patterns in the application, like data access patterns and messaging patterns. These will all go together to build the full application stack. The MVC separates the user interface (UI) of an application into the following three parts − a) The Model − A set of classes that describes the data you are working with as well as the business logic. b) The View − Defines how the application’s UI will be displayed. It is pure HTML that decides how the UI is going to look like. c) The Controller − A set of classes that handles communication from the user, overall application flow, and application-specific logic.

Explain Common web application architectures i.e 1) monolithic application 2) All-in-one applications 3) Layered Architecture 4) Traditional "N-Layer" architecture applications 5) Clean architecture

Image
 Common web application architectures 1)  monolithic application 2)  All-in-one applications 3)  Layered Architecture 4)  Traditional "N-Layer" architecture applications 5)  Clean architecture 1)  monolithic application A monolithic application is one that is entirely self-contained, in terms of its behavior. It may interact with other services or data stores in the course of performing its operations, but the core of its behavior runs within its own process and the entire application is typically deployed as a single unit. If such an application needs to scale horizontally, typically the entire application is duplicated across multiple servers or virtual machines. 2)  All-in-one applications  The smallest possible number of projects for an application architecture is one. In this architecture, the entire logic of the application is contained in a single project, compiled into a single assembly, and deployed as a single unit. A new ASP.NET Core project, whether created in Vis

How does ASP.NET Core process a request?

Image
 How does ASP.NET Core process a request?  A request is received from a browser at the reverse proxy, which passes the request to the ASP.NET Core application, which runs a self-hosted web server. The web server processes the request and passes it to the body of the application, which generates a response and returns it to the webserver. The web server relays this to the reverse proxy, which sends the response to the browser. benefit of a reverse proxy is that it can be hardened against potential threats from the public internet. They’re often responsible for additional aspects, such as restarting a process that has crashed. Kestrel can stay as a simple HTTP server. Think of it as a simple separation of concerns: Kestrel is concerned with generating HTTP responses; a reverse proxy is concerned with handling the connection to the internet.

How does an HTTP web request work?

Image
 How does an HTTP web request work  The user starts by requesting a web page, which causes an HTTP request to be sent to the server. The server interprets the request, generates the necessary HTML, and sends it back in an HTTP response. The browser can then display the web page.  Once the server receives the request, it will check that it makes sense, and if it does, will generate an HTTP response. Depending on the request, this response could be a web page, an image, a JavaScript file, or a simple acknowledgment. As soon as the user’s browser begins receiving the HTTP response, it can start displaying content on the screen, but the HTML page may also reference other pages and links on the server.

Explain ASP.NET Core Architecture Overview with figure.

Image
 ASP.NET Core Architecture Overview  The ideology behind ASP.NET Core in general, as the name suggests, is to lay out web logic, infrastructure, and core components from each other in order to provide a more development-friendly environment.  The concept is somewhat similar to "N" tier/layer architecture, the only difference is that ASP.NET Core defines the layers as the core component of the platform which relieves the developer from redefining it in order to make a solution more modular and reusable.  What happens in ASP.NET Core is that the main business logic and UI logic are encapsulated in the ASP.NET Core Web App layer, while the database access layer, cache services, and web API services are encapsulated in the infrastructure layer and common utilities, objects, interfaces, and reusable business services are encapsulated as micro-services in application core layer.  ASP.NET Core creates necessary pre-defined "N" tier/layers architecture for us developers

Compilation and Execution of .NET applications: CLI, MSIL, and CLR

Image
 Compilation and Execution of .NET applications: CLI, MSIL, and CLR C# programs run on the .NET Framework, which includes the common language runtime (CLR) and a unified set of class libraries. The CLR is the commercial implementation by Microsoft of the common language infrastructure (CLI), an international standard that is the basis for creating execution and development environments in which languages and libraries work together seamlessly. Source code written in C# is compiled into a Microsoft Intermediate Language (MSIL) or simply(IS) that conforms to the CLI specification. The IL code is stored on disk in an executable file called an assembly, typically with an extension of .exe or .dll. CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions. The CLR also provides other services related to automatic garbage collection, exception handling, and resource management. Code that is executed by the CLR is sometimes referred to as "managed

Explain ASP.NET Core with its characteristics , difference between .NET Core and ASP.NET Core.

Image
 ASP.NET Core The new version of the ASP.NET web framework is a free, open-source, and cross-platform framework. ASP.NET Core applications can run on Windows, Linux, and Mac. So you don't need to build different apps for different platforms using different frameworks. It allows you to use and manage modern Ul frameworks such as AngularJS, ReactJS, Umber, Bootstrap, etc. using Bower (a package manager for the web). ASP.NET Core Characteristics It Supports Multiple Platforms Hosting: ASP.NET Core web application can be hosted on multiple platforms with any web server such as IIS, Apache, etc.  It is not dependent only on IIS as a standard .NET Framework. Fast: This reduces the request pipeline and improves performance and scalability. loC Container: It includes the built-in loC container for automatic dependency injection which makes it maintainable and testable. Integration with Modern UI Frameworks Code Sharing: allow to build a class library that can be used with other .NET frame

Explain ASP.NET Web API with its characteristics .

Image
 ASP.NET Web API ASP.NET Web API is a framework for building HTTP services that can be accessed from any client including browsers and mobile devices. It is an ideal platform for building RESTful applications on the .NET Framework. It works more or less the same way as the ASP.NET MVC web application except that it sends data as a response instead of an HTML view. Like a web service or WCF service but the exception is that it only supports HTTP protocol.  ASP.NET Web API Characteristics a framework for building HTTP services that can be accessed from any client including browsers and mobile devices.  Ideal for building RESTful applications on the .NET Framework.  The ASP.NET Web API is an extensible framework for building HTTP-based services that can be accessed in different applications on different platforms such as web, windows, mobile, etc. It works more or less the same way as the ASP.NET MVC web application except that it sends data as a response instead of HTML view. Like a web

Explain ASP.NET MVC Architecture.

Image
 ASP.NET MVC Architecture • MVC stands for Model, View, and Controller. MVC separates an application into three components - Model, View, and Controller.  Model: represents the shape of the data. A class in C# is used to describe a model. Model objects store data retrieved from the database. The model represents the data. • View: View in MVC is a user interface. View display model data to the user and also enables them to modify them. View in ASP.NET MVC is HTML, CSS, and some special syntax (Razor syntax) that makes it easy to communicate with the model and the controller. • Controller: handles the user request. Typically, the user uses the view and raises an HTTP request. Controller processes request and return the appropriate view as a response. The controller is the request handler.

Explain ASP.NET MVC.

 ASP.NET MVC • ASP.NET MVC is an open-source web development framework from Microsoft that provides a Model View Controller architecture. • ASP.net MVC offers an alternative to ASP.net web forms for building web applications. • It is a part of the .Net platform for building, deploying, and running web apps. You can develop web apps and websites with the help of HTML, CSS, JQuery, Javascript, etc.

Explain Features of ASP.NET Web Forms.

 Features of ASP.NET Web Forms • Server Controls- ASP.NET Web server controls are similar to familiar HTML elements, such as buttons and text boxes. Other controls are calendar controls and controls that you can use to connect to data sources and display data. • Master Pages- ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feels and standard behavior for all of the pages (or a group of pages) in your application. You can then create individual content pages along with the master page to render the web page. • Working with Data- ASP.NET provides many options for storing, retrieving, and displaying data in web page Ul elements such as tables and text boxes and drop-down lists. • Server Controls- ASP.NET Web server controls are similar to familiar HTML elements, such as buttons and text boxes. Other controls are calendar controls and controls that you can use to connect to data sources and display