ASP.NET

ASP.NET ( Active Server Pages. NET) is a server side technology from Microsoft for building dynamic web sites, web applications and web services based on the Microsoft NET Framework. Since 2002, ASP.NET is the successor to the original web technology ASP (Active Server Pages).

ASP.NET comes to about 18.7 % of all websites as server-side programming language used and is thus for PHP ( 81.2 %) in second place, the most widely used language for creating Web sites, and of third-placed Java ( 2.7%).

  • 7.1 SOAP Extensions
  • 7.2 mono
  • 7.3 Silverlight as a supplement option

Building ASP.NET

ASP.NET is built on the. NET Framework and provides a method to. NET applications in IIS or other compatible ASP.NET web servers to host. ASP.NET provides this classes that are common to all Web applications, such as authentication and authorization of users. The most important element here is the HTTP runtime to the HTTP handler to process HTTP requests.

With ASP.NET Web applications can (theoretically all CLR - compatible languages ​​) are created in. NET supported languages ​​in use are almost exclusively object-oriented languages ​​like C # and VB.NET. The voice is mostly restricted only by the particular development environment. ASP.NET is thus not a programming language, but a bundle of techniques. ASP.NET languages ​​are not interpreted, but is translated into CIL and compiled.

On the ASP.NET platform set the respective technologies, such as ASP.NET WebForms, ASP.NET AJAX, ASP.NET MVC, ASP.NET Dynamic Data, ASP.NET and ASP.NET WebAPI SignalR to which in each case as HTTP handler are implemented.

ASP.NET Web Forms

The Web Forms. form the basic building block in the development of Web content using ASP.NET in its classical form. Web Forms are stored in files with the extension ". Aspx " included. The. Aspx files typically contain static (X ) HTML markup, as well as the so-called Web Controls and User Controls that are processed according to the server-side logic stored on the web server and displayed as dynamic ( X) HTML code. Examples of Web controls that mitliefert Microsoft by default, a calendar control or the GridView are (table view of data).

Additionally, dynamic code contents that are to be executed by the server within a aspx file in the form <% - dynamic code - %>. Shall be deposited. This type of embedding is very similar to the constructs of other web programming languages ​​like PHP, JSP and ASP. However, the developers should avoid using nested within the HTML code program code because the compiler checks this code only when executed on the Web server. The code separately authored code -behind files (see below) is, however, completely checked by the compiler, which achieves a higher maturity security.

The ASP.NET Framework 2.0, Microsoft released the novel approach of the code -behind model. It will remain static content in the. Aspx file while the dynamic code in aspx.vb a file of type. , Or. Aspx.cs respectively. Aspx.fs is outsourced. The file type is dependent on the use. NET language. Developers who do not want to work with the code -behind approach can override the Render function, and ( completely independent from the design view ) generate the HTML here completely yourself.

Code -behind model

Microsoft recommends using the code-behind approach to dynamic code - shares. The code -behind files usually carry the file extension. Aspx.cs or. Aspx.vb. The file name of the. Aspx corresponds always exactly the name of the code -behind file, only the file extensions are different. Microsoft Visual Studio and other IDEs provide this kind of development by default before. The code of such a code-behind file is compiled before calling the appropriate page. This reduces the error rate than interpreted language in which the error checking only takes place at runtime. In the code - behind file, the developer has the opportunity to respond to a wide variety of events in the life cycle of an ASP Web Forms page, including not only eg loading of the website, but also events that result from user interactions with Web form contents, such as the click of a button.

The program model ( with events that are triggered by controls) is very similar to. NET applications, thus is for developers who have written applications for the. NET framework, the use of ASP.NET ( and C # / VB. NET) easy. Most the functions or classes can be used even without a change in ASP.NET for Windows applications.

With this approach, ASP.NET differs markedly from the classic ASP. A first separation of code used to display and the content is achieved. Similarly, the separation between view and controller in MVC pattern, this separation allows a better division of labor in development, for example, by a division between web designers, the aspx edited, and programmer who created the code - behind file. The newer plugin ASP.NET MVC emphasizes conceptual in much stronger form of this type of separation of concerns.

Directives

With Directives, it is possible to declare in an ASPX file as you want ASP.NET to process this page. The most frequently used directive is <% @ Page %>. This lets you add a variety of settings, especially the indication is programmed in the programming language of dynamic content. For example, in this article contains the code example, the <% @ Page %> directive in the first line.

User Controls

The so-called user controls encapsulate certain sections of pages in a separate file with the extension. Ascx. These. Ascx files are registered within the ASP.NET project and can be used in ASPX pages as well as the predefined Web Controls. The. Ascx files typically contain (X ) HTML markup and server- side controls. A user control is compiled, if the page on which the control is bound, is called. The usercontrol is kept for possible subsequent requests in memory. User Controls bring their own events with it, can also be treated by the developer individually. All user controls are linked thereto, to be called from an aspx page. The direct call a user controls in a browser is not possible.

Individualized Controls

Programmers can define their web applications in ASP.NET custom controls. Unlike User Controls Custom controls are not defined in an ascx file, but its code is compiled into a dynamic link library (DLL) file. If he has such a custom control once defined, the developer can use them in different applications and Visual Studio projects.

These opportunities to develop their own controls for ASP.NET, form the basis for a variety of controls from third- party products that are free or available for a fee. There is now a very large market on which a plurality of re-usable controls are free or are commercially available. Complex requirements must therefore be self- developed often do not.

ViewState

ASP.NET supports an extended opportunity to obtain memory contents between individual page views with the ViewState technology. During the session - state technology with Active Server Pages hitherto existed only a detached by the side calling memory management, the developer has in ASP.NET by enabling customers to store content in a ViewState collection to access it the next page load. In contrast to the session state of the ViewState is not saved on the server, but in the returned page.

With the support of ASP.NET ViewState Engineering Controls maintain their status even over successive page requests. That takes developers from the work, to have to implement this yourself. A similar approach will be taken with the Sun Java Server Faces (JSF ).

WebParts

In addition, ASP.NET provides the concept of WebParts. These intranets may be created in which each user configures what he wants to see at what point the page.

Code Example

Aspx file

The sample code below produces when run on the included web server from Visual Studio, create a basic issue on the screen; this follows the standard content that Microsoft generated when you create a new aspx page ( in ASP.NET 4).

= <% @ Page Title = "Home Page " Language = "C #" MasterPageFile = "~ / Site.master " AutoEventWireup "true"      CodeBehind = " Default.aspx.cs " Inherits = " ASP.NET_Beispiel._Default "%>   < / asp: Content>        

         Welcome to ASP.NET!      < / h2 >     

         To learn more about ASP.NET visit www.asp.net .          

         You can therefore find documentation on ASP.NET at MSDN .         < / source> < / asp: Content> Code -behind file

To the ASP code shown below is part of the quoted source code, which is stored in the code - behind file. In this case, the C # programming language is used to VB.NET is described as a common alternative.

Using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;   namespace ASP.NET_Beispiel {      public partial class _Default: System.Web.UI.Page      {          protected void Page_Load ( object sender, EventArgs e )          {            }      } } Auto Generated. " Designer.cs " file Is also generated a Default.aspx.designer.cs that is always auto generated from the ASPX template. (Or would their changes overwritten ) Since the programmer does not change this file, whose source code is not shown here.

ASP.NET MVC

The ASP.NET MVC Framework is an implementation of the MVC pattern and it allows you to organize dynamic websites particularly clear in the three areas Model ( data model), View ( view) and controller ( control). This is demanded by the underlying architecture and allows clear separation of concerns. MVC also supports in a special way the approach of test-driven development, as with ASP.NET MVC for the " unit tests " Web server is not necessary (in contrast to the situation with WebForms ).

Originally ASP.NET MVC was designed as a plug-in that runs on top WebForms. Meanwhile, however, ASP.NET MVC is an integral part of the ASP.NET framework and WebForms independent.

WebAPI

The WebAPI is a variant of ASP.NET MVC and makes it possible to implement REST web services. Data is transmitted in this case in the form of JSON, XML, or OData.

A Javascript script on a Web page can be accessed with the help of AJAX or AJAJ to these services and thus transfer data in the background. This allows the creation of highly dynamic rich-client web pages.

SignalR

SignalR transfers data between the client and the server using HTML5 WebSockets. If the client's browser can not handle WebSockets, SignalR uses different methods of data transfer as a fallback. SignalR simplifies the implementations of real-time applications such as chatting and video conferencing.

Development environments

Only of historical interest is the Microsoft-supported community project ASP.NET Web Matrix, a development environment for ASP.NET 1.0 and 1.1. For newer versions of ASP.NET, Microsoft recommends instead the use of Visual Web Developer Express as a free development environment or suitable for beginners Microsoft WebMatrix.

Complementary technologies

SOAP Extensions

The ASP.NET SOAP extension framework allows ASP.NET components to process SOAP messages. For creating and connecting with SOAP web services, however, the use of Windows Communication Foundation ( WCF) is recommended.

Mono

In the context of Linux, the Mono project has emphasized the ASP.NET (or. NET Framework in general) makes cross-platform. Currently, ASP.NET 2.0, ASP.NET MVC and ASP.NET AJAX are implemented.

Silverlight as a supplement option

In addition to traditional Web technologies to the ASP.NET relies - ie HTML, CSS and JavaScript - Microsoft has developed the technology Silverlight.

Silverlight (formerly WPF / E) is similar to a Flash browser plugin that tries to circumvent the restrictions of HTML. Unlike Flash, however, the contents ( surface, animation or script ) that the applet in XML to the browser sent (WPF, Windows Presentation Foundation ). This has the consequence that such sites can also be generated easily with server-side code, although this tools ( Expression Blend ) are used.

As with ASP.NET and Silverlight development in the SDK Microsoft Visual Studio is the Microsoft recommended way of programming.

Moonlight is the equivalent of Silverlight in the Mono project.

Web server

  • Microsoft Visual Studio. NET and Visual WebDeveloper Express included from the 2005 version of its own web server, which is why for developing these products no longer IIS is required.
  • Internet Information Services ( IIS 5.0/6.0/7.0 ) from Windows 2000 ( for Windows NT 4 and older, as well as for Windows 9x there is no support ). In contrast to the IIS version 5 ASP.NET on IIS 6 on Windows Server 2003 is implemented directly, making performance improvements could be achieved. IIS is - in a limited way - even in some consumer versions of Windows include (Windows XP Professional, Vista Home Premium Edition from ).
  • Apache web server mod_aspdotnet With the Apache modules and mod_mono ASP.NET can be integrated into the Apache web server. This also works under Linux or BSD.
  • XSP web server (part of the Mono project). This server is available for Windows and Linux, and can be connected via the mod_mono Apache module to the Apache web server. XSP is written in C #, is available under an open source license and supports ASP.NET 2.0 ( no Web Part ).
  • Cassini Web Server. This web server is provided by Microsoft as a lean sample program available and is intended to give developers insight into the workings of ASP.NET Hosting. Cassini is implemented in C # and is available under a shared source license.

Benefits

  • Since the. NET Framework itself provides many functions, many requirements are (such as image editing or XML processing ) as opposed to, for example, PHP without installation of additional libraries possible.
  • By abstracting the functionality used on a web page (of text box on button to complete Calendar Control) server controls browser-independent web pages can be created. In addition, with the CSS Friendly Adaptors on the generated HTML code ( browser- specific) are taken from standard controls influence, so they generate standards compliant HTML, which uses about no tables for layout design. By abstraction, for example, a complete administrative rights (user / roles) - together with login, "Forgot Password", and the like - almost without self- written code, but at least be implemented with ready-made classes in your page. A protection files can be implemented with.

Disadvantages

  • With ASP.NET, you are de facto to a running under operating systems from Microsoft server bound. While there are free. NET ( and ASP.NET ) implementations, but these are not (yet) fully compatible, and therefore lagging new. NET versions always at least a few months afterwards. However, because PHP is by far the most widely used scripting language for web programming to have many web hosts, focusing on Linux platforms, specifically in the area of ​​shared hosting, but rather on PHP / MySQL hosting. This restricts the freedom of choice when hosting a.
  • Since it is proprietary technologies, royalties for the server operating system are due in most cases. This is also true for the development environment if the programmer does not want to be limited to the reduced functionality free versions of Visual Studio.

Revision history

ASP.NET occurred in 2002 with the first version, the successor of the getting on in years ASP (Active Server Pages ) that has now, not much to do other than the name with the old technology. ASP.NET is since 2002 in version 1.0 "final ". Since 28 October 2005, is the final version of ASP.NET 2.0. With ASP.NET 2.0, much less code is needed ( up to 70 percent, according to Microsoft ) to create a dynamic web site. With version 3.5, ASP.NET has been extended to support for Ajax and LINQ. In January 2012, Microsoft released the preview version of ASP.NET 4:01 download free. The latest version 4.5 was released to coincide with the release of. NET Frameworks on 15 August 2012.

Future

Microsoft has introduced in the years 2010 and 2011 the development of MVC plugins driven ( Release 3 ) and ASP.NET 4.0. When MVC plugin effects of newer web frameworks such as Ruby on Rails based on similarities in the paradigms (eg scaffolding ) clearly visible.

About future outlooks regarding ASP.NET Schwichtenberg wrote in the online edition Heise Developer looking back at the Microsoft Professional Developers Conference 2009 in Los Angeles:

" Scott Hunter presented from the development team for the successor of ASP.NET 4.0 some ideas. This includes support for HTML 5, CSS Sprites, data access according to the Active -Record - principle as well as numerous helper classes that improve typical tasks as background tasks and the file upload. Were still not shown the expected long-standing client controls that use JavaScript as well as the server controls with. NET code. "

Pictures of ASP.NET

28034
de