ASP.NET Tutorial/ASP.Net Instroduction/Introduction
Содержание
ASP.NET reserved application folders
Folder Name Description
App_Browsers Contains browser definition files (which are XMLbased files with the .browser extension) used by this application for
identifying and determining the capabilities of browsers.
App_Code Contains any noncodebehind class files to be used by the application.
App_Data Contains application data files, such as SQL Server Express data, Microsoft Access files, or XML data.
App_GlobalResources Contains resource files that are available globally throughout
the application.
App_LocalResources Contains resource files that are associated with a specific page or control.
App_Themes Contains files that define the appearance of pages and controls in the site.
App_WebReferences Contains files used to define references to external Web services.
Bin Contains compiled .NET assemblies (.DLL files).
Notable ASP.net file extension
Extension Description
.asax The Global.asax file defines application-level event handlers.
.ascx Defines a user control. User controls are used to encapsulate a block of reusable user interface functionality.
.ashx Defines a custom HTTP handler. Handlers are used to implement custom response functionality based on the extension of the request.
.asmx Defines an XML Web service.
.aspx Defines a Web Form.
.axd Special handlers used to manage Web site administration requests.
.config An XML-based configuration file (named Web.config) for an application or for the machine itself (machine.config).
.master Defines a master page that specifies the common layout for other Web Forms.
.resx Resource file containing resource strings used for localization.
.sitemap Defines the navigation structure of the site.
.skin Defines the visual property settings to be applied to controls in a site"s theme.
The ASP.NET Framework gives you the most commonly used namespaces
System
System.Collections
System.Collections.Specialized
System.Configuration
System.Text
System.Text.RegularExpressions
System.Web
System.Web.Caching
System.Web.SessionState
System.Web.Security
System.Web.Profile
System.Web.UI
System.Web.UI.WebControls
System.Web.UI.WebControls.WebParts
System.Web.UI.HTMLControls
System.Web.Extensions
System.Xml.Linq
System.Data.DataSetExtensions
The default namespaces are listed inside the pages element in the root web configuration file
located at the following path:
\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\Web.Config
Before you can use a class contained in an assembly in your application,
you must add a reference to the assembly.
By default, an ASP.NET application references the most common assemblies contained in the Global Assembly Cache:
mscorlib.dll
System.dll
System.Configuration.dll
System.Web.dll
System.Data.dll
System.Web.Services.dll
System.Xml.dll
System.Drawing.dll
System.EnterpriseServices.dll
System.Web.Mobile.dll
Your first ASP.net page
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load()
{
lblServerTime.Text = DateTime.Now.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>First Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
The current date and time is:
<asp:Label
id="lblServerTime"
Runat="server" />
</div>
</form>
</body>
</html>
The first line contains a directive. It looks like this:
<%@ Page Language="C#" %>
The code declaration block contains all the methods used in the page.
It contains all the page"s functions and subroutines.
<script runat="server">
void Page_Load()
{
lblServerTime.Text = DateTime.Now.ToString();
}
</script>