ASP.NET: Difference between revisions
Deleted a wrong claim that exceptions could bring the worker process down. Exceptions are caught by the runtime and leads to an error page. |
|||
Line 54: | Line 54: | ||
[[Active Server Pages]] Classic (ASP) and ASP.NET can be run side-by-side in the same web application. This approach allows developers to migrate applications slowly instead of all at once. On [[Internet Information Services|IIS]] 6.0 and lower, pages written using different versions of the ASP framework can't 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 [[Internet Information Services|IIS]] 7. With [[Internet Information Services|IIS]] 7, modules may be run in an integrated pipeline that allows modules written in any language to be executed for any request.<ref>[http://www.iis.net/default.aspx?tabid=2&subtabid=23&i=1223|Differences between IIS 7.0 Integrated Mode and Classic mode]</ref> |
[[Active Server Pages]] Classic (ASP) and ASP.NET can be run side-by-side in the same web application. This approach allows developers to migrate applications slowly instead of all at once. On [[Internet Information Services|IIS]] 6.0 and lower, pages written using different versions of the ASP framework can't 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 [[Internet Information Services|IIS]] 7. With [[Internet Information Services|IIS]] 7, modules may be run in an integrated pipeline that allows modules written in any language to be executed for any request.<ref>[http://www.iis.net/default.aspx?tabid=2&subtabid=23&i=1223|Differences between IIS 7.0 Integrated Mode and Classic mode]</ref> |
||
In some |
In some cases ASP.NET runtime will recycle the worker process (e.g. if it becomes unresponsive or if an application runs amok and causes the worker process to use more than 60% of available RAM). It can also be configured to recycle the process proactively after a certain number of request, time period etc. In these cases users may loose session state if the application is configured to use in-process sessions. If the application relies on session state to store authentication information (bad practice since cookie based authentication and membership is built into the framework) and the application is configured to use in-process sessions, the user may be logged out if the process is recycled. |
||
ASP.NET 2.0 produces markup that passes W3C validation, but it is debatable as to whether this increases [[Web accessibility|accessibility]]; one of the benefits of a semantic [[XHTML]] page + [[CSS]] representation. Several controls, such as the ''[[Login]]'' controls and the ''Wizard'' control, use [[HTML]] [[Table (HTML)|tables]] for layout by default. (''[[Microsoft]] has now gone some way to solve this problem by releasing the [http://www.asp.net/cssadapters/ ASP.NET 2.0 CSS Control Adapters], a free add-on that produces compliant accessible [[XHTML]]+[[CSS]] markup.'') However, some controls still rely on [[JavaScript]]. The [[CSS]] Control Adapters do help override output, even if it is to improve [[HTML]], not [[CSS]]. |
ASP.NET 2.0 produces markup that passes W3C validation, but it is debatable as to whether this increases [[Web accessibility|accessibility]]; one of the benefits of a semantic [[XHTML]] page + [[CSS]] representation. Several controls, such as the ''[[Login]]'' controls and the ''Wizard'' control, use [[HTML]] [[Table (HTML)|tables]] for layout by default. (''[[Microsoft]] has now gone some way to solve this problem by releasing the [http://www.asp.net/cssadapters/ ASP.NET 2.0 CSS Control Adapters], a free add-on that produces compliant accessible [[XHTML]]+[[CSS]] markup.'') However, some controls still rely on [[JavaScript]]. The [[CSS]] Control Adapters do help override output, even if it is to improve [[HTML]], not [[CSS]]. |
Revision as of 00:32, 15 May 2007
ASP.NET is a web application framework marketed by Microsoft. Programmers can use it to build dynamic web sites, web applications and XML web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology.
ASP.NET is built on the Common Language Runtime, meaning programmers can write ASP.NET code using any Microsoft .NET language.
ASPX file format
ASPX is a text file format used to create Webform pages; in programming jargon, the ASPX file typically contains static HTML or XHTML markup, as well as markup defining Web Controls and Web User Controls where the developer places all the required static and dynamic 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, but this practice is generally discouraged except for Databinding.
The recommended method for dealing with dynamic program code is to use the code-behind model, which places this code in a separate file or in a specially designated script tag. Code-behind files are typically named something to the effect of MyPage.aspx.cs or MyPage.aspx.vb based on the ASPX file name (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 walk through the document.
Other files
Other file extensions associated with different versions of ASP.NET include:
- asax - Global.asax, used for application-level logic and event handling[1]
- ascx - Web UserControls: custom controls to be placed onto web pages.
- ashx - custom HTTP handlers
- asmx - web service pages.
- axd - when enabled in web.config requesting trace.axd outputs application-level tracing.
- browser - browser capabilities files stored in XML format; introduced in version 3.0. ASP.NET 2 includes many of these by default, to support common web browsers. These specify which browsers have which capabilities, 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 - 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, so as to allow configuration changes to be made with simplicity.
- cs/vb - In ASP.NET 2 any cs/vb files placed inside the App_Code folder are dynamically compiled and available to the whole application.
- master - Master Pages; introduced in version 2.0
- sitemap - sitemap configuration files
- skin - theme skin files.
Performance
ASP.NET aims for performance benefits over other script-based technologies ( including ASP Classic ) by compiling the server-side code to one or a few DLL files on the web server. 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 delay to the web user when the newly-edited page is first requested from the web server.
The ASPX and other resource files are placed in a virtual host on an Internet Information Services (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.
Developers can also choose to pre-compile their code before deployment, eliminating the need for just-in-time compilation in a production environment.
ASP.NET compared to ASP classic
ASP.NET attempts to simplify 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 counterpart: 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 part of the resulting page sent to the end-user's browser.
ASP.NET encourages the programmer to develop applications using an event-driven GUI paradigm (event-driven GUI model), rather than in conventional web-scripting environments like ASP and PHP. The framework attempts to combine 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 ASP classic are:
- Compiled code means applications run faster with more design-time errors trapped at the development stage.
- Significantly improved run-time error handling, making use of exception handling using try-catch blocks.
- Similar metaphors to Windows applications such as controls and events, which make development of rich user interfaces, previously only found on the desktop, possible.
- An extensive set of controls and class libraries allows the rapid building of applications, plus user-defined controls allow commonly used templates, such as menus. Layout of these controls on a page is easier because most of it can be done visually in most editors.
- ASP.NET leverages the multi-language capabilities of the .NET CLR, allowing web pages to be coded in VB.NET, C#, J#, etc.
- Ability to cache the whole page or just parts of it to improve performance.
- Ability to use the code-behind development model to separate business logic from presentation.
- If an ASP.NET application leaks memory, the ASP.NET runtime unloads the AppDomain hosting the erring application and reloads the application in a new AppDomain.
- Session state in ASP.NET can be saved in a SQL Server database or in a separate process running on the same machine as the web server or on a different machine. That way session values are not lost when the web server is reset or the ASP.NET worker process is recycled.
- Previous versions of ASP.NET (1.0 and 1.1) were criticized for their lack of standards compliance. The generated HTML and JavaScript sent to the client browser would not always validate against W3C/ECMA standards. In addition, the framework's browser detection feature sometimes incorrectly identified web browsers other than Microsoft's own Internet Explorer as "downlevel" and returned HTML/JavaScript to these clients that was crippled or broken. However, in version 2.0, all controls generate valid HTML 4.0, XHTML 1.0 (the default) or XHTML 1.1 output, depending on the site configuration. Detection of standards-compliant web browsers is more robust and support for Cascading Style Sheets is more extensive.
* Web Server Controls: These are the most powerful controls introduced by ASP.net for providing the UI for the web form. These controls are state managed controls and are WYSWYG (What You See What You Get) controls.
Criticisms of ASP.NET
Active Server Pages Classic (ASP) and ASP.NET can be run side-by-side in the same web application. This approach allows developers to migrate applications slowly instead of all at once. On IIS 6.0 and lower, pages written using different versions of the ASP framework can't 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, modules may be run in an integrated pipeline that allows modules written in any language to be executed for any request.[2]
In some cases ASP.NET runtime will recycle the worker process (e.g. if it becomes unresponsive or if an application runs amok and causes the worker process to use more than 60% of available RAM). It can also be configured to recycle the process proactively after a certain number of request, time period etc. In these cases users may loose session state if the application is configured to use in-process sessions. If the application relies on session state to store authentication information (bad practice since cookie based authentication and membership is built into the framework) and the application is configured to use in-process sessions, the user may be logged out if the process is recycled.
ASP.NET 2.0 produces markup that passes W3C validation, but it is debatable as to whether this increases accessibility; one of the benefits of a semantic XHTML page + CSS representation. Several controls, such as the Login controls and the Wizard control, use HTML tables for layout by default. (Microsoft has now gone some way to solve this problem by releasing the ASP.NET 2.0 CSS Control Adapters, a free add-on that produces compliant accessible XHTML+CSS markup.) However, some controls still rely on JavaScript. The CSS Control Adapters do help override output, even if it is to improve HTML, not CSS.
Development tools
Several available software packages exist for developing ASP.NET applications:
- Microsoft Expression Web Designer (available now), part of the forthcoming Microsoft Expression Studio application suite.
- Visual Studio .NET or Visual Studio 2005 or Visual Web Developer 2005 Express Edition (for ASP.NET 2.0)
- ASP.NET Web Matrix (ASP.NET 1.x only, was free, now no longer supported: replaced by the free Visual Web Developer 2005 Express Edition)
- Macromedia Dreamweaver MX, Macromedia Dreamweaver MX 2004, or Macromedia Dreamweaver 8 (doesn't support ASP.NET 2.0 features, and produces very inefficient code for ASP.NET 1.x: also, code generation and ASP.NET features support through version 8.0.1 was little if any changed from version MX: version 8.0.2 does add changes to improve security against SQL injection attacks)
- Macromedia HomeSite 5.5 (For ASP Tags)
- Microsoft SharePoint Designer 12
- Delphi 2006
- MonoDevelop (Free/Open Source)
- SharpDevelop (Free/Open Source)
History
Date | Version | Remarks | New features |
---|---|---|---|
January 16, 2002 | 1.0 | First version released together with Visual Studio .NET |
|
April 24, 2003 | 1.1 | released together with Windows Server 2003 released together with Visual Studio .NET 2003 |
|
November 7, 2005 | 2.0 |
codename Whidbey |
|
On January 23, 2007, Microsoft released version 1.0 of ASP.NET AJAX, an extension for ASP.NET.
ASP.NET team members
Various ASP.NET team members maintain blogs. Here are some of them:
- Scott Guthrie, General Manager - http://weblogs.asp.net/scottgu
- Nikhil Kothari, Architect - http://www.nikhilk.net
- Brian Goldfarb, Product Manager - http://blogs.msdn.com/bgold
- Shanku Niyogi, Product Unit Manager - http://www.shankun.com
- Bertrand Le Roy, Developer - http://weblogs.asp.net/bleroy
- Harish Ranganathan, Developer Evangelist - http://geekswithblogs.net/ranganh
See also
- Active Server Pages (ASP) – ASP.NET's predecessor
- ASP master pages
- Yellow Screen of Death – ASP.NET's Exception page
- Java Server Faces (JSF) – web application technology with a similar component based approach for the Java plattform
- ASP.NET AJAX – Extension for AJAX enabled ASP.NET pages
Resources about ASP.NET
- Pro ASP.NET 2.0 in C# 2005, Matthew MacDonald, Apress, November 27, 2005. ISBN 1-59059-496-7
- ASP.NET 2.0 Unleashed, Stephen Walther, Sams Publishing, June 6, 2006. ISBN 0-672-32823-2
- Essential ASP.NET With Examples in C#, Fritz Onion, Addison-Wesley Professional, February 11, 2003. ISBN 0-201-76040-1
- Programming ASP.NET, Jessy Liberty & Dan Hurwitz, O'Reilly, October, 2005. ISBN 0-596-00916-X
- ASP.NET 2.0 Website Programming , Marco Bellinaso, Wrox, May, 2006. ISBN 0-7645-8464-2
Other implementations
- Mono - An open source .NET Framework implementation that runs on many platforms
- UltiDev Cassini Web Server - A free web server that can be redistributed with ASP.NET 1.1 and 2.0 applications