Microsoft ASP.NET Programming with Microsoft Visual Basic .NET Version 2003 Step By Step
You’ll see a number of new file types in your ASP.NET applications. To avoid any confusion, let’s take a minute to go over the ones you’ll see most often and discuss how they’re used.
-
.aspx The extension you’ll see most often. Analogous to the .asp extension in classic ASP, .aspx is used for Web Forms pages.
-
.ascx The extension used for Web Forms user controls. User controls provide one of the many ways available in ASP.NET to reuse code. Similar to include files in classic ASP, .ascx files can be as simple as a few HTML tags or can include complex logic that the author might want to reuse in many pages. User controls are added to a Web Forms page using the @ Register directive, which is discussed in Part III.
-
.asmx The extension used for files that implement Web services. Web services can be accessed directly through .asmx files, or the .asmx file can direct the request to a compiled assembly that implements the Web service.
-
.vb The extension for Visual Basic .NET code modules. All Web Forms pages (.aspx) added to a Visual Studio .NET Web application that are written in Visual Basic .NET will have a corresponding .vb code-behind module with the same name as the Web Form page to which it’s related (pagename.aspx.vb).
-
.resx Denotes a resource file. These files are used primarily in Windows Forms applications, but are also available to Web application developers for storing resources such as alternative text strings for internationalization of applications.
-
Global.asax Used to define Application- and Session-level variables and startup procedures. Global.asax is used the same way as Global.asa is used in classic ASP. Note that while Global.asax can be structured like Global.asa, with startup procedures such as Session_OnStart (Session_Start in ASP.NET) coded directly in the Global.asax file in a <script runat=“server”> block, Visual Studio implements these procedures in a .vb (or .cs) code-behind module (global.asax.vb) rather than in the Global.asax file itself.
In addition to the functionality available in a classic ASP Global.asa file, which was used for handling Application and/or Session start and end events and declaring Application- and/or Session-level variables, ASP.NET also allows you to import namespaces, link to assemblies, and perform other useful tasks. You’ll learn more about Global.asax in Chapter 7.
-
Web.config A new file type in ASP.NET, used to solve one of the major hassles with classic ASP applications: configuration. The Web.config file is a human- and machine-readable XML-based file that stores all of the configuration settings for a given application (or segment of an application). Web.config files are interpreted hierarchically—a Web.config file in a subdirectory of your application will override the settings of the Web.config file (or files) in its parent directories. The advantage is that configuration settings can be inherited where that is desirable, but you also have very granular control over configuration.
Категории