ASP.NET is an open source server side web application template designed for web development to generate dynamic web pages. It was developed by Microsoft to enable programmers to build dynamic websites, web applications and web services.
It was first released in January 2002 with version 1.0 of the.NET Framework, and is the successor of Microsoft's Active Server Pages (ASP) technology. ASP.NET is built in Common Language Runtime (CLR), allowing programmers to write ASP.NET code using supported.NET languages. The ASP.NET SOAP extension framework allows the ASP.NET component to process SOAP messages.
The replacement for ASP.NET is ASP.NET Core. This is a re-implementation of ASP.NET as a modular web framework, along with other frameworks like the Entity Framework. New framework using new open source. NET Compiler Platform (codename "Roslyn") and cross platform. ASP.NET MVC, ASP.NET Web APIs, and ASP.NET Web Pages (platforms that only use the Razor page) have been merged into the integrated MVC 6.
Video ASP.NET
Characteristics
ASP.NET Web pages, officially known as Web Forms, are the main building blocks for application development in ASP.NET. There are two basic methodologies for Web Forms, web application formats and website formats. Web applications must be compiled before deployment, while website structure allows users to copy files directly to server without previous compilation. The web form is contained in a file with the extension ".aspx"; these files usually contain static HTML markup (X) or component markup. Component markup can include server-side Web Controls and User Controls that have been defined within the template or web page. For example, the textbox component can be defined on the page as & lt; asp: id textbox = 'myid' runat = 'server' & gt;
, which is rendered into an html input box. Additionally, dynamic code, which runs on the server, can be placed on pages within the & lt;% - dynamic code -% & gt;
, which is similar to other Web development technologies like PHP, JSP, and ASP. With ASP.NET Framework 2.0, Microsoft introduced a new code-behind model that allows static text to remain on the.aspx page, while dynamic code stays in.aspx.vb or.aspx.cs or. the aspx.fs file (depending on the programming language used).
Model behind code
Microsoft recommends dealing with dynamic program code by using the code model behind, which places this code in a separate file or within a specified designated script tag. The code behind files usually have a name like " MyPage.aspx.cs" or " MyPage.aspx.vb" while the page file is MyPage.aspx (the same filename as the page file (ASPX), but with the final extension indicating the page language). This practice is automated in Visual Studio and other IDEs, although the user can change the page behind the code. Also, in web application format, pagename.aspx.cs is a partial class that links to pagename.designer.cs file. The designer file is an autogenerated file of the ASPX page and allows the programmer to reference the component on an ASPX page from the CS page without having to declare it manually, as required in the ASP.NET version before version 2. While using this programming style, the developer writes the code to respond to different events, such as pages loaded, or controls that are clicked, rather than the procedural guides of the document.
The ASP.NET code-behind model marks the departure of Classic ASP as it encourages developers to build applications with the separation of presentations and content in mind. In theory, this will allow a Web designer, for example, to focus on design markup with less potential to interfere with the programming code that drives it. This is similar to the controller split from view in the model-view-controller (MVC) framework.
Referrals
Referrals are specific instructions on how ASP.NET should process the page. The most common instructions are & lt;% @ Page% & gt;
, which can determine many of the attributes used by ASP.NET page parsers and compilers.
User control
User Controls is the encapsulation section of the listed page section and used as a control in ASP.NET Custom control
The programmer can also build special controls for ASP.NET applications. Unlike user controls, this control does not have an ASCX markup file, after all their code is compiled into a dynamic library link file (DLL). The custom controls can be used in some Web applications and Visual Studio 2013 projects.
rendering Techniques
.NET uses a "visiting composite" rendering technique. During compilation, the template file (.aspx) is compiled into an initialization code that builds a control tree (composite) that represents the original template. The text literally goes into the Literal control class instance, and the server control is represented by instances of a particular control class. Initialization code is combined with user-written code (usually with the assembly of some partial classes) and generates a special class for the page. This page doubles as the root of the control tree.
The actual request for a page is processed through a number of steps. First, during the initialization steps, an instance of the page class is created and the initialization code is executed. This produces an initial control tree, which is now usually manipulated by the page method in the following steps. Since each node in the tree is a control represented as a derivative of the class, the code can change the tree structure as well as manipulate the properties of individual nodes. Finally, as long as the visitor rendering step is used to visit each node in the tree, request each node to create itself using the visitor method. The resulting HTML output is sent to the client.
After the request is processed, the page class instance is removed and with it the entire tree controls. This is a source of confusion among ASP.NET starter programmers who rely on missing sample class members with every request page/response cycle.
Country management
The ASP.NET application is hosted by a Web server and is accessed using an HTTP protocol without a country. Thus, if an application uses state interaction, it must apply its own state management. ASP.NET provides various functions for state management. Conceptually, Microsoft treats "state" as a GUI state. Problems may arise if the app must track "data status"; for example, a state-limited machine that may be in a transient state between requests (lazy evaluation) or takes a long time to initialize. Country management on ASP.NET pages with authentication can make Web scratch difficult or impossible.
Apps
The app's status is held by a set of user-defined shared variables. This is set and initialized when the Application_OnStart
event is lit while loading the first instance of the app and is available until the last instance exits. The app status variables are accessed using the Applications
collection, which provides wrappers for application status. Application status variables are identified by name. Application is state management.
Session status
The server-side session status is held by a collection of user defined user-defined session variables during the user session. These variables, accessed using the Session
collection, are unique for each instance session. Variables can be set to automatically be destroyed after the inactive time is specified even if the session does not end. Sided-client user sessions are managed by cookies or by encoding session IDs in the URL itself.
ASP.NET supports three persistency modes for server-side session variables:
- In process mode
- Session variables are retained in the ASP.NET process. This is the fastest way; However, in this mode the variables are destroyed when the ASP.NET process is recycled or closed.
- Country server mode
- ASP.NET runs a separate Windows service that maintains status variables. Because state management takes place outside the ASP.NET process, and since ASP.NET engines access data using.NET Remoting, ASPState is slower than In-Process. This mode allows ASP.NET applications to load-balanced and scaled across multiple servers. Because the state management service runs independently of ASP.NET, session variables can persist throughout the ASP.NET process. However, because the server state of the session runs as one instance, it's still a single point of failure for session status. The session-state service can not be loaded, and there are restrictions on the types that can be stored in session variables.
- SQL Server Mode
- The status variables are stored in the database, which allows session variables to persist throughout the ASP.NET process. The main advantage of this mode is to allow the application to balance the load on the cluster server, sharing sessions between servers. This is the slowest method of session state management in ASP.NET.
ASP.NET session state allows you to store and retrieve values ââfor users when users navigate ASP.NET pages in a Web application. HTTP is a no-state protocol. This means that the Web server treats each HTTP request for a page as an independent request. The server does not store knowledge of the value of the variable used during the previous request. The ASP.NET session state identifies requests from the same browser over a limited period of time as a session, and provides a way to maintain variable values ââfor the duration of the session. By default, the ASP.NET session state is enabled for all ASP.NET applications.
Alternative to session status includes the following:
- The status of the app, which stores variables that all ASP.NET app users can access.
- Profile properties, which retain user value in data storage without expiration.
- caching ASP.NET, which stores the values ââin memory available for all ASP.NET applications.
- View status, which stores values ââin a single page.
- Cookies.
- Query string and fields on the HTML form available from HTTP requests.
View the state
View country refers to a page-level state management mechanism, which is used by HTML pages emitted by an ASP.NET app to maintain control status and Web form widgets. The control state is encoded and sent to the server on each form submission in a hidden field known as __ VIEWSTATE
. The server sends back the variable so that when the page is rendered back, the control is made to its final state. On the server side, the app can change display conditions, if processing requires any control status change. Individual control status is decoded on the server, and is available for use on ASP.NET pages using the ViewState
collection.
The main use for this is to keep the form information across the back post. View status is enabled by default and usually creates serial data in every control on the page regardless of whether it is actually used during postback. This behavior can (and should) be modified, since Display status can be disabled on a per-control, per-page, or entire server basis.
Developers must be careful in storing sensitive or personal information in the Page view or control status, because the base64 string that contains data view data can be easily initialized. By default, Display state does not encrypt __ VIEWSTATE
values. Encryption can be enabled on a server (and server-specific) basis, allowing certain security levels to be maintained.
server-side caching
ASP.NET offers a "Cache" object that is shared across applications and can also be used to store objects. The "Cache" object stores data for only the specified time.
More
Other ways of state management supported by ASP.NET are cookies, caching, and query strings.
Template engine
When first released, ASP.NET does not have a template engine. Because the.NET Framework is object-oriented and allows inheritance, many developers will define new base classes that inherit from " System.Web.UI.Page
", write the method there that renders HTML, and then create a page in their applications inherit from this new class. While this allows common elements to be reused in a site, it adds complexity and mixes the source code with markup. Furthermore, this method can only be tested visually by running the app - not while designing it. Other developers have used included files and other tricks to avoid having to apply the same navigation and other elements on every page.
ASP.NET 2.0 introduces the concept of the master page , which allows the development of template-based pages. Web applications may have one or more master pages, which, beginning with ASP.NET 2.0, may be repeated. The master template has a place-holder control, called ContentPlaceHolders to indicate where dynamic content is running, as well as HTML and JavaScript shared across the child pages.
The child page uses the ContentPlaceHolder control, which should be mapped to the holder where the master page filled the content page. The rest of the page is defined by the parts that are shared from the master page, much like a mail merge in a word processor. All markup and server controls on content pages must be placed in the ContentPlaceHolder control.
When a request is made for a content page, ASP.NET merges the output of the content page with the output of the master page, and sends the result to the user.
The master page remains fully accessible to the content page. This means that the content page can still manipulate titles, change titles, configure cache, etc. If the master page exposes a public property or method (for example, to set a copyright notice), the content page may use it as well.
Other files
Other file extensions associated with various versions of ASP.NET include:
Directory structure
In general, the ASP.NET directory structure can be determined by the developer preferences. Regardless of some directory names that are backed up, the site can reach a number of directories. The structure is usually reflected directly in the URL. Although ASP.NET provides a means to intercept a request at any point during processing, the developer is not forced to enter a request through a central application or a front controller.
Special directory names (from ASP.NET 2.0 on) are:
- App_CodeÃ,
- This is the "raw code" directory. The ASP.NET server automatically compiles files (and subdirectories) in this folder into assemblies that can be accessed in the code of every page of the site. App_Code is typically used for data access abstraction codes, model codes, and business codes. Also any site-specific http handlers and modules and Web service implementation are logged in this directory. As an alternative to using App_Code, developers can choose to provide separate assembly with compiled code.
- App_DataÃ,
- The ASP.NET App_Data directory is the default directory for any database that is used by the ASP.NET Website. This database may include an Access (mdb) or SQL Server (mdf) file. App_Data is the only directory with Write access enabled for ASP.NET web app.:
- App_GlobalResourcesÃ,
- Save a resx file with available local resources for each page of the site. This is where ASP.NET developers usually store localized messages, etc. Used on more than one page.
- App_LocalResourcesÃ,
- E.g., a file named CheckOut.aspx.fr-FR.resx stores local resources for the French version of the CheckOut.aspx page. When the UI culture is set to France, ASP.NET automatically finds and uses this file for localization.
- App_Offline.htmÃ,
- Files (not directories) that disable apps by restoring file contents for any app requests.
- App_ThemesÃ,
- Add a folder that stores theme-related files, which is a new ASP.NET feature that helps ensure consistent look throughout the website and makes it easier to change the look of the website when needed.
- App_WebReferencesÃ,
- save discovery files and WSDL files for reference to Web services to be consumed on the site.
- BinÃ,
- Contains compiled code (.dll file) for any controls, components, or other code you want to reference in your application. Each class that is represented by the code in the Bin folder is automatically referenced in your application.
Maps ASP.NET
Performance
ASP.NET aims to benefit performance over other script-based technologies (including Classic ASP) by compiling server-side code when first used for one or more DLL files on a Web server. This dll file or assembly contains Microsoft Intermediate Language (MSIL) to run in common language runtime; this provides more performance improvements than pure scripted languages ââand is similar to the approach used by Python and is no different from JavaServer Pages. This compilation occurs automatically the first time the page is requested (which means the developer does not need to perform a separate compilation step for the page).
This feature provides the ease of development offered by the scripting language with the performance benefits of a compiled binary. However, compilation may cause a real but short delay for users when the first edited page is first requested from the Web server, but no longer unless the requested page is updated further.
ASPX and other resource files are placed in the virtual host on the Internet Information Services server (or another compatible ASP.NET server; see other Implementations, below). The first time a client requests a page, the.NET Framework parses and compiles files into.NET and sends a response; the next request is served from the DLL file. By default ASP.NET compiles the entire site in a batch of 1000 files upon first request. If compilation delays cause problems, batch sizes or compilation strategies can be changed.
Developers can also choose to pre-compile their "codebehind" files before deployment, using Microsoft Visual Studio, eliminating the need for timely compilation in a production environment. It also eliminates the need to have the source code on the Web server. It also supports pre-compiled text.
Extensions
Microsoft has released several extension frameworks that connect to ASP.NET and expand its functionality. Some of them are:
- ASP.NET Handler
- Is a component that implements the
System.Web.IHttpHandler
interface. Unlike ASP.NET Pages, they do not have HTML-markup files, no events and other support. All they have is code-files (written in.NET-compatible languages) that write some data to the HTTP server response. HTTP handlers are similar to ISAPI extensions. - ASP.NET AJAX
- Extension with both client side as well as server side components to write ASP.NET pages that combine Ajax functionality.
- ASP.NET MVC
- A framework extension for ASP.NET page authors uses a model-view-controller (MVC) architecture.
- ASP.NET Razor
- Alternate Web Page View for Web Forms designed for use with MVC since release 3.
- ASP.NET Dynamic Data âââ â¬
- Scaffold extensions for creating data-driven web apps â ⬠<â â¬
- ASP.NET Web API
- HTTP API Framework to expose web services.
- ASP.NET SignalR
- Real-time communication framework for two-way communication between client and server.
ASP.NET compared to Classic ASP
ASP.NET WebForms simplifies developer transition from Windows application development to Web development by offering the ability to build pages consisting of control similar to Windows user interface. Web controls, such as the button or label , work in a way very similar to their Windows counterparts: the code can set its properties and respond to events. The control knows how to create itself: whereas the Windows control draws to the screen, the web control generates HTML and JavaScript segments that form part of the results page sent to the end user's browser.
ASP.NET WebForms encourages programmers to develop applications using event-driven GUI models, rather than in conventional Web scripting environments such as ASP and PHP. The framework incorporates existing technologies such as JavaScript with internal components such as "ViewState" to bring persistent (inter-request) to a Web environment without a country that is inherently absent.
Another difference compared to Classic ASP is:
- The compiled code means that the app runs faster with more design-time errors caught in the development stage.
- Significantly improved run-time error handling, utilizing exception handling using try-catch blocks.
- Similar metaphors for Microsoft Windows applications such as controls and events.
- A broad set of classroom controls and libraries, as well as user-defined controls, enables quick application creation. The layout of this control on the page is easier because most can be done visually in most editors.
- ASP.NET uses multilingual capabilities from.NET Common Language Runtime, enabling Web pages to be encoded in VB.NET, C #, J #, Delphi.NET etc.
- Ability to save entire pages or only part to improve performance.
- Ability to use the code development model behind to separate the business logic from the presentation.
- Ability to use the correct object oriented design for page and programming control
- If an ASP.NET application leaks memory, the ASP.NET runtime unpacks the AppDomain hosting the wrong app and reloads the app in the new AppDomain.
- The session status in ASP.NET can be stored in a Microsoft SQL Server database or in a separate process that runs on the same machine as the Web server or on a different machine. That way the session values ââare not lost when the web server is reset or the ASP.NET worker process is recycled.
- The ASP.NET version before 2.0 was criticized for lack of standard compliance. The generated HTML and JavaScript sent to the client browser will not always validate against W3C/ECMA standards. In addition, the framework browser detection feature sometimes incorrectly identifies the Microsoft Web browser other than Microsoft's own Internet Explorer as "downlevel" and returns HTML/JavaScript to this client with some features deleted, or sometimes defective or damaged. But in version 2.0, all controls produce valid HTML 4.0, XHTML 1.0 (standard) or XHTML 1.1 output, depending on site configuration. A more robust standard web browser detection and support for more extensive Cascading Style Sheets.
- Web Server Controls: these are the controls introduced by ASP.NET WebForms to provide UIs for Web forms. This control is state-controlled and is a WYSIWYG control.
IIS integrated pipeline
In IIS 6.0 and lower, pages written using different versions of the ASP template can not share session status without using third-party libraries. This does not apply to ASP.NET and ASP applications running side by side on IIS. 7. With IIS 7.0, modules can be run in an integrated pipeline that allows modules to be written in any language to be executed for any request.
Development tools
There are several software packages available for developing ASP.NET applications:
Framework
It is not essential to use a standard Web form development model when developing with ASP.NET. Key frameworks designed for the platform include:
- The Base One Foundation Component Library (BFC) is a RAD framework for building.NET databases and distributed computing applications.
- DotNetNuke is an open-source solution that provides a web application framework and content management system that allows for extended renewal through modules, skins, and providers.
- Castle MonoRail, an open-source MVC framework with an execution model similar to Ruby on Rails. This frame is usually used with Castle ActiveRecord, an ORM layer created in NHibernate.
- Spring.NET, the port of the Spring framework for Java.
Version
The ASP.NET release history is strongly associated with the release of the.NET Framework:
Other implementations
The Mono project supports "everything in.NET 4.5 except WPF, WWF, and with limited WCF and ASP.NET 4.5 stacked async stacks." ASP.NET can be run with Mono using one of three options: Apache hosting using mod_mono module, FastCGI hosting, and XSP.
References
Quote
Source
- MacDonald, Matthew; Szpuszta, Mario (2005). Pro ASP.NET 2.0 in C # 2005 (1st ed.). Apress. ISBNÃ, 1-59059-496-7.
Further reading
- Anne Boehm: Murachs ASP.NET 3.5 Web Programming with VB 2008 , July 21, 2008, Mike Murach and Associates, ISBN 978-1-890774-47-9
- Stephen Walther: ASP.NET 3.5 Unleashed , December 28, 2007, Sams Publishing, ISBN 0-672-33011-3 ISBNÃ, 0-672-33011-3
- Stephen Walther: Data Access in ASP.NET 2.0 Framework (Video Training) , September 26, 2007, Sams Publishing, ISBN 0-672-32952-2
External links
- Official website
- ASP.NET in Curlie (based on DMOZ)
- ASP.NET on MSDN
- Some new features in ASP.NET 4 and vs 2010 IDE
Source of the article : Wikipedia