• Login/Register
  • Section: Internet /Monday 26th January 2015

    Alphabetic Index : A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

    Search β):

    * ASP.NET *

    ای‌اس‌پی‌دات‌نت


    Iranian_Flag_Hand_Love_Heart.jpg
    (Wikipedia) - ASP.NET Not to be confused with UNESCO ASPNet. ASP.NET (ASP Dot NET) Developer(s) Initial release Stable release Preview release Written in Operating system Type License Website
    Microsoft
    January 2002
    4.5 / 15 August 2012; 2 years ago (2012-08-15)
    5.0 / 12 November 2014; 2 months ago (2014-11-12)
    .NET languages
    Microsoft Windows
    Web application framework
    Apache 2.0
    www.asp.net
    ASP.NET Filename extension Internet media type Developed by
    .aspx, .cshtml, .vbhtml
    text/html
    Microsoft

    ASP.NET is an open source server-side Web application framework designed for Web development to produce dynamic Web pages. It was developed by Microsoft to allow programmers to build dynamic web sites, web applications and web services.

    It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft''s Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language. The ASP.NET SOAP extension framework allows ASP.NET components to process SOAP messages.

    ASP.NET is in the process of being re-implemented as a modern and modular web framework, together with other frameworks like Entity Framework. The new framework will make use of the new open-source .NET Compiler Platform (code-name "Roslyn") and be cross platform. ASP.NET MVC, ASP.NET Web API, and ASP.NET Web Pages (a platform using only Razor pages) will merge into a unified MVC 6. The project is called "ASP.NET vNext".

    Contents

    History

    After four years of development, and a series of beta releases in 2000 and 2001, ASP.NET 1.0 was released on January 5, 2002 as part of version 1.0 of the .NET Framework. Even prior to the release, dozens of books had been written about ASP.NET, and Microsoft promoted it heavily as part of its platform for Web services. Scott Guthrie became the product unit manager for ASP.NET, and development continued apace, with version 1.1 being released on April 24, 2003 as a part of Windows Server 2003. ASP.NET is loosely based on HTML. This release focused on improving ASP.NET''s support for mobile devices.

    Characteristics

    ASP.NET Web pages, known officially as Web Forms, are the main building blocks for application development. Web forms are contained in files with a ".aspx" extension; these files typically contain static (X)HTML markup, as well as markup defining server-side Web Controls and User Controls where the developers place all the rc content for the Web page. Additionally, dynamic code, which runs on the server, can be placed in a page within a block <% -- dynamic code -- %>, which is similar to other Web development technologies such as PHP, JSP, and ASP. With ASP.NET Framework 2.0, Microsoft introduced a new code-behind model which allows static text to remain on the .aspx page, while dynamic code remains in an .aspx.vb or .aspx.cs or .aspx.fs file (depending on the programming language used).

    Code-behind model

    Microsoft recommends dealing with dynamic program code by using the code-behind model, which places this code in a separate file or in a specially designated script tag. Code-behind files typically have names like MyPage.aspx.cs or MyPage.aspx.vb while the page file is MyPage.aspx (same filename as the page file (ASPX), but with the final extension denoting the page language). This practice is automatic in Microsoft Visual Studio and other IDEs. When using this style of programming, the developer writes code to respond to different events, like the page being loaded, or a control being clicked, rather than a procedural walkthrough of the document.

    ASP.NET''s code-behind model marks a departure from Classic ASP in that it encourages developers to build applications with separation of presentation and content in mind. In theory, this would allow a Web designer, for example, to focus on the design markup with less potential for disturbing the programming code that drives it. This is similar to the separation of the controller from the view in Model–View–Controller (MVC) frameworks.

    Directives

    A directive is a special instruction on how ASP.NET should process the page. The most common directive is <%@ Page %> which can specify many attributes used by the ASP.NET page parser and compiler.

    <!-- Web.Config Configuration File --><configuration> <system.web> <customErrors mode="On"/> </system.web> </configuration>User controls

    User controls are encapsulations of sections of pages which are registered and used as controls in ASP.NET, org,etc.

    Custom controls

    Programmers can also build custom controls for ASP.NET applications. Unlike user controls, these controls do not have an ASCX markup file, having all their code compiled into a dynamic link library (DLL) file. Such custom controls can be used across multiple Web applications and Visual Studio projects.

    Rendering technique

    ASP.NET uses a "visited composites" rendering technique. During compilation, the template (.aspx) file is compiled into initialization code which builds a control tree (the composite) representing the original template. Literal text goes into instances of the Literal control class, and server controls are represented by instances of a specific control class. The initialization code is combined with user-written code (usually by the assembly of multiple partial classes) and results in a class specific for the page. The page doubles as the root of the control tree.

    Actual requests for the page are 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 the initial control tree which is now typically manipulated by the methods of the page in the following steps. As each node in the tree is a control represented as an instance of a class, the code may change the tree structure as well as manipulate the properties/methods of the individual nodes. Finally, during the rendering step a visitor is used to visit every node in the tree, asking each node to render itself using the methods of the visitor. The resulting HTML output is sent to the client.

    After the request has been processed, the instance of the page class is discarded and with it the entire control tree. This is a source of confusion among novice ASP.NET programmers who rely on the class instance members that are lost with every page request/response cycle.

    State management

    ASP.NET applications are hosted by a Web server and are accessed using the stateless HTTP protocol. As such, if an application uses stateful interaction, it has to implement state management on its own. ASP.NET provides various functions for state management. Conceptually, Microsoft treats "state" as GUI state. Problems may arise if an application needs to keep track of "data state"; for example, a finite-state machine which may be in a transient state between requests (lazy evaluation) or which takes a long time to initialize. State management in ASP.NET pages with authentication can make Web scraping difficult or impossible.

    Application

    Application state is held by a collection of shared user-defined variables. These are set and initialized when the Application_OnStart event fires on the loading of the first instance of the application and are available until the last instance exits. Application state variables are accessed using the Applications collection, which provides a wrapper for the application state. Application state variables are identified by name. Application is state management.

    Session state

    Server-side session state is held by a collection of user-defined session variables that are persistent during a user session. These variables, accessed using the Session collection, are unique to each session instance. The variables can be set to be automatically destroyed after a defined time of inactivity even if the session does not end. Client-side user session is maintained by either a cookie or by encoding the session ID in the URL itself.

    ASP.NET supports three modes of persistence for server-side session variables:

    In-process mode The session variables are maintained within 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 shut down. State server mode ASP.NET runs a separate Windows service that maintains the state variables. Because state management happens outside the ASP.NET process, and because the ASP.NET engine accesses data using .NET Remoting, ASPState is slower than In-Process. This mode allows an ASP.NET application to be load-balanced and scaled across multiple servers. Because the state management service runs independently of ASP.NET, the session variables can persist across ASP.NET process shutdowns. However, since session state server runs as one instance, it is still one point of failure for session state. The session-state service cannot be load-balanced, and there are restrictions on types that can be stored in a session variable. SQL Server mode State variables are stored in a database, allowing session variables to be persisted across ASP.NET process shutdowns. The main advantage of this mode is that it allows the application to balance load on a server cluster, sharing sessions between servers. This is the slowest method of session state management in ASP.NET.

    ASP.NET session state enables you to store and retrieve values for a user as the user navigates ASP.NET pages in a Web application. HTTP is a stateless protocol. This means that a Web server treats each HTTP request for a page as an independent request. The server retains no knowledge of variable values that were used during previous requests. ASP.NET session state identifies requests from the same browser during a limited time window as a session, and provides a way to persist variable values for the duration of that session. By default, ASP.NET session state is enabled for all ASP.NET applications.

    Alternatives to session state include the following:

    For a comparison of different state-management options, see ASP.NET State Management Recommendations Session

    View state

    View state refers to the page-level state management mechanism, utilized by the HTML pages emitted by ASP.NET applications to maintain the state of the Web form controls and widgets. The state of the controls is encoded and sent to the server at every form submission in a hidden field known as __VIEWSTATE. The server sends back the variable so that, when the page is re-rendered, the controls render at their last state. At the server side, the application may change the viewstate, if the processing requires a change of state of any control. The states of individual controls are decoded at the server, and are available for use in ASP.NET pages using the ViewState collection.

    The main use for this is to preserve form information across postbacks. 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 postback. This behavior can (and should) be modified, however, as View state can be disabled on a per-control, per-page, or server-wide basis.

    Developers need to be wary of storing sensitive or private information in the View state of a page or control, as the base64 string containing the view state data can easily be de-serialized. By default, View state does not encrypt the __VIEWSTATE value. Encryption can be enabled on a server-wide (and server-specific) basis, allowing for a certain level of security to be maintained.

    Server-side caching

    ASP.NET offers a "Cache" object that is shared across the application and can also be used to store various objects. The "Cache" object holds the data only for a specified amount of time and is automatically cleaned after the session time-limit elapses.

    Other

    Other means of state management that are supported by ASP.NET are cookies, caching, and using the query string.

    Template engine

    When first released, ASP.NET lacked a template engine. Because the .NET Framework is object-oriented and allows for inheritance, many developers would define a new base class that inherits from "System.Web.UI.Page", write methods there that render HTML, and then make the pages in their application inherit from this new class. While this allows for common elements to be reused across a site, it adds complexity and mixes source code with markup. Furthermore, this method can only be visually tested by running the application – not while designing it. Other developers have used include files and other tricks to avoid having to implement the same navigation and other elements in every page.

    ASP.NET 2.0 introduced the concept of "master pages", which allow for template-based page development. A Web application can have one or more master pages, which, beginning with ASP.NET 2.0, can be nested. Master templates have place-holder controls, called ContentPlaceHolders to denote where the dynamic content goes, as well as HTML and JavaScript shared across child pages.

    Child pages use those ContentPlaceHolder controls, which must be mapped to the place-holder of the master page that the content page is populating. The rest of the page is defined by the shared parts of the master page, much like a mail merge in a word processor. All markup and server controls in the content page must be placed within 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 output to the user.

    The master page remains fully accessible to the content page. This means that the content page may still manipulate headers, change title, configure caching etc. If the master page exposes public properties or methods (e.g. for setting copyright notices) the content page can use these as well.

    Other files

    Other file extensions associated with different versions of ASP.NET include:

    Extension Introduced in version Description
    asax 1.0 This is the global application file.You can use this file to define global variables (Variable that can be accessed from any Web page in the Web application.) It is mostly used to define the overall application event related to application & session object.Global.asax, used for application-level logic
    ascx 1.0 User Control, used for User Control files logic
    ashx 1.0 custom HTTP handlers Do not have a user interface.
    asmx 1.0 Web service pages. From version 2.0 a Code behind page of an asmx file is placed into the app_code folder.
    aspx 1.0 An ASP.NET Web Forms page that can contain Web controls and presentation and business logic. http://msdn.microsoft.com/en-us/library/2wawkw1c.aspx
    axd 1.0 when enabled in web.config requesting trace.axd outputs application-level tracing. Also used for the special webresource.axd handler which allows control/component developers to package a component/control complete with images, script, css etc. for deployment in one file (an ''assembly'')
    browser 2.0 browser capabilities files stored in XML format; introduced in version 2.0. ASP.NET 2 includes many of these by default, to support common Web browsers. These specify which browsers have which abilities, so that ASP.NET 2 can automatically customize and optimize its output accordingly. Special .browser files are available for free download to handle, for instance, the W3C Validator, so that it properly shows standards-compliant pages as being standards-compliant. Replaces the harder-to-use BrowserCaps section that was in machine.config and could be overridden in web.config in ASP.NET 1.x.
    config 1.0 web.config is the only file in a specific Web application to use this extension by default (machine.config similarly affects the entire Web server and all applications on it), however ASP.NET provides facilities to create and consume other config files. These are stored in XML format.
    cs/vb/fs 1.0 Code files (cs indicates C#, vb indicates Visual Basic, fs indicates F#). Code behind files (see above) predominantly have the extension ".aspx.cs" or ".aspx.vb" for the two most common languages. Other code files (often containing common "library" classes) can also exist in the Web folders with the cs/vb extension. In ASP.NET 2 these should be placed inside the App_Code folder where they are dynamically compiled and available to the whole application.
    cshtml 4.1 Views (mixed C# and HTML using Razor syntax)
    dbml 3.5 LINQ to SQL data classes file
    edmx 3.5 ADO.NET Entity Framework model
    master 2.0 master page file. Default file name is Master1.master
    resx 1.0 resource files for internationalization and localization. Resource files can be global (e.g. messages) or "local" which means specific for one aspx or ascx file.
    sitemap 2.0 sitemap configuration files. Default file name is web.sitemap
    skin 2.0 theme skin files.
    svc 3.0 Windows Communication Foundation service file
    vbhtml 4.1 Views (mixed VB and HTML using Razor syntax)
    Directory structure

    In general, the ASP.NET directory structure can be determined by the developer''s preferences. Apart from a few reserved directory names, the site can span any number of directories. The structure is typically reflected directly in the URLs. Although ASP.NET provides means for intercepting the request at any point during processing, the developer is not forced to funnel requests through a central application or front controller.

    The 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 an assembly which is accessible in the code of every page of the site. App_Code will typically be used for data access abstraction code, model code and business code. Also any site-specific http handlers and modules and Web service implementation go in this directory. As an alternative to using App_Code the developer may opt to provide a separate assembly with precompiled code. App_Data  The App_Data ASP.NET Directory is the default directory for any database used by the ASP.NET Website. These databases might include Access (mdb) files or SQL Server (mdf) files. The App_Data is the only directory with Write Access enabled for the ASP.NET web application.: App_LocalResources  E.g. a file called CheckOut.aspx.fr-FR.resx holds localized resources for the French version of the CheckOut.aspx page. When the UI culture is set to French, ASP.NET will automatically find and use this file for localization. App_GlobalResources  Holds resx files with localized resources available to every page of the site. This is where the ASP.NET developer will typically store localized messages etc. which are used on more than one page. App_Themes  Adds a folder that holds files related to themes which is a new ASP.NET feature that helps ensure a consistent appearance throughout a Web site and makes it easier to change the Web site’s appearance when necessary. App_WebReferences  holds discovery files and WSDL files for references to Web services to be consumed in the site. Bin  Contains compiled code (.dll files) for controls, components, or other code that you want to reference in your application. Any classes represented by code in the Bin folder are automatically referenced in your application.Performance

    ASP.NET aims for performance benefits over other script-based technologies (including classic ASP) by compiling the server-side code the first time it is used to one or more DLL files on the Web server. These dll files or assemblies contain Microsoft Intermediate Language (MSIL) for running within the common language runtime; this provides a performance boost over pure scripted languages and is similar to the approach used by Python and not dissimilar to java server pages. This compilation happens automatically the first time a page is requested (which means the developer need not perform a separate compilation step for pages).

    This feature provides the ease of development offered by scripting languages with the performance benefits of a compiled binary. However, the compilation might cause a noticeable but short delay to the Web user when the newly edited page is first requested from the Web server, but will not again unless the page requested is updated further.

    The ASPX and other resource files are placed in a virtual host on an Internet Information Services server (or other compatible ASP.NET servers; see Other implementations, below). The first time a client requests a page, the .NET Framework parses and compiles the file(s) into a .NET assembly and sends the response; subsequent requests are served from the DLL files. By default ASP.NET will compile the entire site in batches of 1000 files upon first request. If the compilation delay is causing problems, the batch size or the compilation strategy may be tweaked.

    Developers can also choose to pre-compile their "codebehind" files before deployment, using Microsoft Visual Studio, eliminating the need for just-in-time compilation in a production environment. This also eliminates the need of having the source code on the Web server. It also supports pre-compile text.

    Extension

    Microsoft has released some extension frameworks that plug into ASP.NET and extend its functionality. Some of them are:

    ASP.NET AJAX An extension with both client-side as well as server-side components for writing ASP.NET pages that incorporate AJAX functionality. ASP.NET MVC Framework An extension to author ASP.NET pages using the model–view–controller (MVC) architecture.ASP.NET Razor view engine An alternative view to Web Forms designed for use with MVC since release 3.ASP.NET Dynamic Data A scaffolding extension to build data driven web applications ASP.NET Web API An HTTP API framework for exposing web services. ASP.NET SignalR A real-time communications framework for bi-directional communication between client and server.ASP.NET compared with classic ASP

    ASP.NET simplifies developers'' transition from Windows application development to Web development by offering the ability to build pages composed of controls similar to a Windows user interface. A Web control, such as a button or label, functions in very much the same way as its Windows counterparts: code can assign its properties and respond to its events. Controls know how to render themselves: whereas Windows controls draw themselves to the screen, Web controls produce segments of HTML and JavaScript which form parts of the resulting page sent to the end-user''s browser.

    ASP.NET encourages the programmer to develop applications using an event-driven GUI model, rather than in conventional Web-scripting environments like ASP and PHP. The framework combines existing technologies such as JavaScript with internal components like "ViewState" to bring persistent (inter-request) state to the inherently stateless Web environment.

    Other differences compared to classic ASP are:

    Criticism

    On IIS 6.0 and lower, pages written using different versions of the ASP framework cannot share session state without the use of third-party libraries. This criticism does not apply to ASP.NET and ASP applications running side by side on IIS 7. With IIS 7.0, modules may be run in an integrated pipeline that allows modules written in any language to be executed for any request.

    Development tools

    Several available software packages exist for developing ASP.NET applications:

    Software Developer Licensing
    Wiwet ASP.NET Templates Avalon Commercial
    ASP.NET Intellisense Generator BlueVision LLC Free
    Microsoft Visual Studio Microsoft Free and commercial
    Microsoft Visual Web Developer Express Microsoft Registerware
    CodeGear Delphi Embarcadero Technologies Commercial
    Macromedia HomeSite Adobe Systems Commercial
    Microsoft Expression Web Microsoft Free
    Microsoft SharePoint Designer Microsoft Free
    MonoDevelop Novell and the Mono community Free open source
    SharpDevelop ICSharpCode Team Free open source
    Eiffel for ASP.NET Eiffel Software Free open source and commercial
    Adobe Dreamweaver Adobe Systems Commercial
    Stadium Twenty57 Commercial, free beta
    Frameworks

    It is not essential to use the standard Web forms development model when developing with ASP.NET. Noteworthy frameworks designed for the platform include:

    Versions

    The ASP.NET releases history tightly correlates with the .NET Framework releases:

    Date Version Remarks New ASP.NET related features
    January 16, 2002 Old version, no longer supported: 1.0 First version

    released together with Visual Studio .NET

    • Object-oriented Web application development supporting inheritance, polymorphism and other standard OOP features
      • Developers are no longer forced to use Server.CreateObject(...), so early-binding and type safety are possible.
    • Based on Windows programming; the developer can make use of DLL class libraries and other features of the Web server to build more robust applications that do more than simply rendering HTML (e.g. exception handling)
    April 24, 2003 Old version, no longer supported: 1.1 released together with Windows Server 2003

    released together with Visual Studio .NET 2003

    • Mobile controls
    • Automatic input validation
    November 7, 2005 Old version, no longer supported: 2.0

    codename Whidbey released together with Visual Studio 2005 and Visual Web Developer Express and SQL Server 2005

    • New data controls (GridView, FormView, DetailsView)
    • New technique for declarative data access (SqlDataSource, ObjectDataSource, XmlDataSource controls)
    • Navigation controls
    • Master pages
    • Login controls
    • Themes
    • Skins
    • Web parts
    • Personalization services
    • Full pre-compilation
    • New localization technique
    • Support for 64-bit processors
    • Provider class model
    November 21, 2006 Old version, no longer supported: 3.0
    • Windows Presentation Foundation (WPF)
    • Windows Workflow Foundation (WF)
    • Windows Communication Foundation which can use ASP.NET to host services.
    • Windows CardSpace which uses ASP.NET for login roles.
    November 19, 2007 Old version, no longer supported: 3.5 Released with Visual Studio 2008 and Windows Server 2008
    • New data controls (ListView, DataPager)
    • ASP.NET AJAX included as part of the framework
    • Support for HTTP pipelining and syndication feeds.
    • WCF support for RSS, JSON, POX and Partial Trust
    • All the .NET Framework 3.5 changes, like LINQ etc.
    August 11, 2008 Old version, no longer supported: 3.5 Service Pack 1 Released with Visual Studio 2008 Service Pack 1
    • Incorporation of ASP.NET Dynamic Data
    • Support for controlling browser history in an ASP.NET AJAX application
    • Ability to combine multiple JavaScript files into one file for more efficient downloading
    • New namespaces System.Web.Abstractions and System.Web.Routing
    April 12, 2010 Older version, yet still supported: 4.0

    Parallel extensions and other .NET Framework 4 features

    The two new properties added in the Page class are MetaKeyword and MetaDescription.

    August 15, 2012 Current stable version: 4.5 Released with Visual Studio 2012 and Windows Server 2012 for Windows 8

    Parallel extensions and other .NET Framework 4.5 features

    Legend: Old version Older version, still supported Latest version Latest preview version Future release
    Other implementations

    The Mono Project supports "everything in .NET 4.5 except WPF, WF, limited WCF, and limited ASP.NET 4.5 async stack." ASP.NET can be run with Mono using one of three options: Apache hosting using the mod_mono module, FastCGI hosting, and XSP.

    Notes
  • ^ ASP.NET 5 Overview | The ASP.NET Site
  • ^ "ASP.NET is part of a great open source .NET community". Microsoft. May 14, 2013. 
  • ^ ASP.NET 5 Overview | The ASP.NET Site
  • ^ "Show #19 – LIVE! from the PDC". The MSDN Show. Microsoft. November 15, 2001. Retrieved 2008-04-20. 
  • ^ Staff (November 2001). "Overview of ASP.NET and Web Forms". Microsoft. Retrieved 2011-06-05. 
  • ^ (MacDonald & Szpuszta 2005, p. 63)
  • ^ "Code Behind vs. Code Inline". Microsoft .NET Framework. Microsoft. Archived from the original on 11 November 2010. Retrieved 2010-11-22. 
  • ^ "ASP.NET Web Page Syntax Overview". Microsoft .NET Framework. Microsoft. Retrieved 2010-11-22. 
  • ^ a b c "INFO: ASP.NET State Management Overview". Retrieved 2007-10-23. 
  • ^ "ViewState in ASP.NET". Archived from the original on 14 October 2007. Retrieved 2007-10-23. 
  • ^ "ASP.NET ViewState Overview". 
  • ^ "Encrypting Viewstate in ASP.NET". Retrieved 2009-07-19. 
  • ^ ASP.NET Master Pages Overview (Microsoft Developer Network)
  • ^ Global.asax Syntax
  • ^
  • ^ ASP.NET Web Site Layout from MSDN
  • ^ ASP.NET Directory Structure
  • ^ (MacDonald & Szpuszta 2005, pp. 7–8)
  • ^ How to Take Advantage of the IIS 7.0 Integrated Pipeline
  • ^ "Compatibility – Mono". Retrieved 2014-02-02. 
  • Tags:ASP.NET, ASP.NET MVC Framework, Adobe, Adobe Dreamweaver, Apache, Basic, Cascading, Cascading Style Sheets, Communication, Data, Default, Dynamic, Eiffel, French, HTML, HTTP, Internet, Internet Explorer, JSON, Java, LLC, Microsoft, Navigation, PHP, RSS, Ruby on Rails, SOAP, UNESCO, WYSIWYG, Web application, Web application framework, Web development, Web page, Web server, Web service, Website, Wikipedia, Windows, XHTML, XML


    See also items containing : ASP.NET

    Failed to connect to MySQL 1: Access denied for user 'foumanu'@'localhost' (using password: YES)