ASP.NET 4.5 Essentials

Discussion in 'ASP.NET' started by MinalS, Mar 17, 2015.

  1. MinalS

    MinalS New Member

    Joined:
    Jul 8, 2014
    Messages:
    138
    Likes Received:
    32
    Trophy Points:
    0
    The engine used in ASP.NET 4.5 is similar to the previous versions of ASP.NET. The new features of the ASP.NET 4.5 are as mentioned below:

    ASP.NET Core Services



    ASP.NET 4.5 contains features like encoding routines, minification, bundling, etc. The core services are as mentioned below:

    1. ASP.NET request validation

    It allows the user to read unvalidated request data even if the validation is enabled. Two new features as lazy request validation and unvalidated request data are introduced. In ASP.NET 4.5 requests are validated by default. User can configure the application for accepting the request before the actual data. This validation is known as lazy request validation.

    User can enable it by adding the following code in the web.config file.

    Code:
    <httpRuntime requestValidationMode=”4.5” … />
    
    ASP.NET 4.5 provides access to the unvalidated request data. To use this property, add the requestValidationMode = “4.5” in the httpRuntime element in the web.config file.

    2. Reading and writing HTTP requests and responses

    It provides the capacity of reading and writing the HTTP request asynchronously.

    3. Supports the WebSockets protocol

    It enables user to create a secure bi-directional communication between the client and the server. The protocol is supported by clients and server. The protocol contains resources for client and mobile operating systems. ASP.NET 4.5 contains System.Web.WebSockets namespace containing classes like AspNetWebSocket, AspNetWebSocketOptions. It can asynchronously read and write binary data using API.

    4. Minification

    The JavaScript and CSS files contain whitespaces. These are removed using the minification.

    5. Bundling

    User can create bundles of JavaScript and CSS files using the combination of both them. They are created using the Bundle class or child classes as StyleBundle or ScriptBundle. Once the instance of the class is created, the instance is added to global collection of web application. The BundleConfig file does the configuration for handle creation of core scripts. The files are sorted alphabetically and added in the library.

    6. Integrated Anti – XSS encoding routines

    It helps user to perform anti cross site scripting. The cross site scripting is the major problem to the web site security. If there is lack of security, the attackers can add the client side script to the database can access the confidential information.

    Routines are implemented using the AntiXssEncoder class present in the System.Web.Security.AntiXss namespace.

    7. Supports OAuth and OpenID

    User can create web sites for assigning the permissions to the user to log in with the credentials created on different sites. OAuth is the open standard for authorization providing users to access the resources through credentials.

    OpenID is the open standard for authenticating users. User can create account using the OpenID identity providers and the account can be used to access the web site supporting the ID.

    ASP.NET Web Forms



    The web forms are the essential component in the web applications. The new features introduced in the ASP.NET 4.5 are as listed below:

    1. Binding expressions in data controls

    It helps user to write strongly type, two way binding expressions for data control. The complex properties of the data control can be used.

    2. Model Binders

    User can bind data controls directly using the data access methods. The concept is similar to the model binding.

    3. HTML encoded data binding expression

    User can encode the data binding expression in the HTML format using the colon at the end of the <%# prefix stating the ends of the expression.

    4. JavaScript for client side

    The client validation code is added into a single file reducing the page size and page load. The caching of files is better.

    5. CDN support in the control

    The EnableCdn property of the ScriptManager control is useful for checking that the script was loaded successfully from a CDN. If there is a problem in loading, the script is loaded in different location.

    6. Paging in GridView control

    It improves the paging functionality through the AllowCustomPaging and VirtualItemCount properties of the control.

    7. HTML 5 form types support

    It states the changes done to the web form controls for using the advantages of HTML5. The FileUpload control is used for uploading multiple files to the browser. The TextBox control supports HTML5 input types. HTML5 inputs are validated using the HTML5 validation control. The UpdatePanel control is modified for supporting the HTML5 input fields.

    ASP.NET Web Pages 2



    ASP.NET Web pages 2 are useful when user needs to combine the HTML and server code for creating light weighted web content. User can connect easily to the database and several links can be added.

    The new features added into the ASP.NET Web pages 2 are as mentioned below:
    1. Display modes - User can create device specific web pages that can be rendered in the mobile devices.
    2. New site templates - There are several site templates like starter site, personalization site which are useful for site upgrade. In personalized site templates user can add, gallery and other information. The user can sign in to the websites using the starter template.
    3. Side by side support - User can execute two applications simultaneously on the same machine.
    4. Improvements in syntax - There are conditional attributes provided by the user which are useful for reducing the complexity of the attributes for the values mentioned by the user.
    5. Membership and authentication - The OAuth and OpenID are the two authentication provided in this version. User can sign into external sites using the credentials.

    ASP.NET Technologies



    In ASP.NET 4.5, several technologies are integrated for developing web sites easy for developers. The common platform for developers helps them handle complicated databases in efficient manner. Some of the integrated technologies are as mentioned below:
    1. ADO.NET Entity framework - The entity framework helps user to design models and map the databases, tables through Visual Studio and .net framework. User needs to convert relational form and apply it to the database schema or relational model.
    2. ADO.NET Data Services Framework - The ADO.NET Data Services framework contains patterns and libraries that helps user to create and consume data services for the web. The clients can consume across internet or in a intranet. The flexible data services are created and integrated in the web.
    3. Silverlight technology - The technology helps the designer and developers to extent the web application boundaries. It can execute in cross browser, cross platform, and cross device environment. It helps user to develop web applications containing multimedia content with good visual effects.
    4. MVC Framework - It is an architectural design useful for software engineering. It is easy to split an application into separate layers of UI logic, data access layer for accessing on different devices. The presentation layer contains two parts as controller and view.
    5. Data Framework - The dynamic framework helps user to built data driven web applications on the entity framework data model. The information about the data is present in the database.
    6. ASP.NET Web API - It helps user to build HTTP services. The RESTful services are developed using the .NET framework. The features of the ASP.NET Web API are as stated below:
      1. User can easily build HTTP services that can be accessed by clients.
      2. User can directly access and manipulate HTTP requests and responses.
      3. The data is retrieved from the HTTP request
      4. The route parameters and constraints are added.

    ASP.NET Life Cycle



    The ASP.NET life cycle is initiated when the client requests a page from the web server. The ISAPI.dll assembly present in the web server checks the file extension requested by the user. The dll forwards the request to IIS where the inetinfo.exe is executed to create an instance of the worker process. The class instance is used to process the request.

    The ASP.NET life cycle displays how the ASP.NET processes the web pages for dynamic output.

    Life Cycle of ASP.NET Web Page

    When a web page is requested by the user, it goes through the number of stages. This process is known as life cycle of web page. The page request is considered as beginning of the web page and the page rendering is the completion of the browser. When user needs to perform particular action or custom control for a project, the life cycle is useful.

    ASP.NET Web pages pass through different stages. They are as mentioned below:
    1. Page request - It states the life cycle of the page is started when user requests a web page. If the user executes the web page for the first time, the page is compiled and executed. If the request is old one, the cached copy of the page is sent.
    2. Start - It is referred when the Request and Response properties of the web page. The IsPostBack property is used whether the request is old or new one.
    3. Page Initialization - It is used when each control of the page is assigned a ID using the UniqueID property. The themes are added to the page.
    4. Load - It states the stage in which the current request is an old, the properties of controls on the page are loaded with data from view to control state.
    5. PostBack event handling - It specifies the request is an old, then the event handler is added. Once the validation controls on the web page, the Validate() method is used.
    6. Rendering - It checks that before the page rendering, the view state of all the controls on the page are saved. The Render() method is invoked for each control on the web page. The OutputStream object of the Response property is used for rendering the output for page.
    7. Unload - It refers when the Response and Request properties of the page are unloaded.

    The events of the ASP.NET Life cycle



    The life cycle of a page consists of events used for handling the code. The automatic event wire up is supported by the web pages. When an event is raised, the ASP.NET searches for methods corresponding to the event. The AutoEventWireUp attribute of the @Page directive is set to true.

    Some of the common page events are as listed below:
    1. PreInit: The first event of the life cycle of the ASP.NET page is referred as PreInit. The IsPostBack property of the page is checked for processing of the page. The dynamic controls are created.
    2. Init: It is the event raised after the initialization of the controls and the skin settings are applied.
    3. Load: The OnLoad() method is used to set the properties of the control and maintain database connections.

    Creation of ASP.NET 4.5 application



    In ASP.NET 4.5 application, user can create web and web sites. The dynamic data feature works with both web and windows application projects. There are several project types available. User needs to understand them.

    Web application

    The web application stored information of the files included in the ASP.NET project. It needs the user to build the project in the Visual Studio application. During compilation, the classes and standalone files are grouped into a single assembly.

    The namespaces are added to pages, controls, and classes by default. User needs to copy the assembly created during the project compilation in the IIS Server. The assembly needs to be copied created by the user during the compilation of the project in IIS server.

    Web site

    It does not contain any project files. The files are added automatically to the website. The website is dynamically compiled by ASP.NET. Multiple assemblies are created. The namespaces are manually added. They are not added by default to the web pages, controls and classes. User needs to copy the project source to the IIS server.

    Let’s create a simple web application using Visual Studio 2012.
    1. Click Start, select All Programs, Select Microsoft Visual Studio 2012 option.
    2. The Start Page for Visual Studio 2012 is as shown below.

      [​IMG]
    3. Select File, New, Project option from the studio 2012.
    4. Select Web, click ASP.NET web forms application from the center pane.
    5. Add the application name in the text box.
    6. Add the location for saving the application in the Location combo box.
    7. Click OK button and the application is created in the system.

    Components of Visual Studio 2012



    There are several components of Visual Studio 2012. Some of them are explained below:

    1. ToolBox

    The toolbox control contains number of tabs. Every tab consists of controls that can be added to the web form by dragging them. It is located on the left side of the Visual Studio 2012. User can access the toolbox by clicking View, Toolbox from the menu bar. The keys CTRL + ALT + X keys are used to open.

    [​IMG]

    2. Server Explorer

    The server explorer is used to display the servers available from where the data is accessed. User can view the window by clicking View, Server Explorer window. The keys CTRL + ALT + S are used to open the explorer.

    [​IMG]

    3. Solution explorer

    The solution explorer window is used to provide the project overview where the project elements are managed. It is displayed in the tree view format. The explorer can be opened by selecting View, Solution Explorer. The keys CTRL + ALT + L are used to open the explorer.

    [​IMG]

    4. Toolbars

    They provide an easy access to the Visual Studio 2012. Different toolbars for every category is provided. From the Tools menu, user can add new toolbars as Formatting, Build can be viewed.

    5. Properties Window

    The properties for the control on the web forms can be easily set through the window. Using the View, Properties window user can select it. The F4 key can also be used for opening the window.
     
    Last edited by a moderator: Jan 21, 2017

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice