|
ASP.NET Project Files
In this page we will take a close look at the files that are created as part of a
Web Application. When you open a new Web Application in Visual Studio .NET, in
the Solution Explorer Window you will notice the following files that are already
created as part of the Application: AssemblyInfo.vb, Global.asax, Style.css, Web.Config,
Projectname.vsdisco and WebForm.aspx.
AssemblyInfo.vb
An assembly is the building block of an ASP.NET application. The AssemblyInfo.vb file
contains information about the assembly, it's version number, dependencies, etc. The
AssemblyInfo.vb file looks as follows:
Imports System.Reflection
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
<Assembly: AssemblyTitle("")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("")>
<Assembly: AssemblyCopyright("")>
<Assembly: AssemblyTrademark("")>
<Assembly: CLSCompliant(True)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("6ACEB232-291B-4EEC-8462-FEBD203D084B")>
' Version information for an assembly consists of the following four values:
' ' Major Version
' Minor Version
' Build Number
' Revision
' ' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
<Assembly: AssemblyVersion("1.0.*")>
|
Global.asax
The Global.asax file, also known as the ASP.NET application file, is an optional file
that contains code for responding to application-level events raised by ASP.NET or
by HTTP modules. The Global.asax file resides in the root directory of an ASP.NET
based application. At run time, Global.asax is parsed and compiled into a dynamically
generated .NET Framework class derived from the HttpApplication base class. The Global.asax
file itself is configured so that any direct URL request for it is automatically rejected.
External users cannot download or view the code written within it. The Global.asax
file is optional. If you do not define the file, the ASP.NET page framework assumes
that you have not defined any application or session event handlers. The Global.asax
file looks as follows:
Imports System.Web
Imports System.Web.SessionState
Imports System.Diagnostics
Public Class Global Inherits System.Web.HttpApplication
#Region " Component Designer Generated Code "
#End Region
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session is started
End Sub
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires at the beginning of each request
End Sub
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires upon attempting to authenticate the use
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application ends
End Sub
End Class
|
Style.css
The Style.css file is a cascading style sheet file that holds styles for the page.
Using this file you can customize the appearance of your Web pages as it sets the
styles used. You can define your own styles in this file and use them in your Web
pages. To use style sheets a good working knowledge of HTML is essential. The Style.css
file looks as follows:
/* Default CSS Stylesheet for a new Web Application project */
BODY
{ BACKGROUND-COLOR: white;
FONT-FAMILY: Verdana, Helvetica, sans-serif;
FONT-SIZE: .8em;
FONT-WEIGHT: normal;
LETTER-SPACING: normal;
TEXT-TRANSFORM: none;
WORD-SPACING: normal
}
H1, H2, H3, H4, H5, TH, THEAD, TFOOT
{
COLOR: #003366;
}
TFOOT, THEAD {
font-size: 1em;
word-spacing: normal;
letter-spacing: normal;
text-transform: none;
font-family: Arial, Helvetica, sans-serif;
}
A:link {
text-decoration: none;
color: #3333cc;
}
A:visited {
text-decoration: none;
color: #333399;
}
A:active {
text-decoration: none;
color: #333399;
}
A:hover {
text-decoration: underline;
color: #3333cc;
}
'Most of the Style.css file is omitted for the purpose of explanation.
'You can find the full file in your Web Applciation project
|
Web.Config
The Web.Config file is an XML based file that contains configuration information for
ASP.NET resources. This file contains information about how the server will handle
your application. You can set options for security, permissions, tracing, etc in this
file. The Web.Config file looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to insert debugging symbols (.pdb information)
into the compiled page. Because this creates a larger file that executes
more slowly, you should set this value to true only when debugging and to
false at all other times. For more information, refer to the documentation about
debugging ASP.NET files.
-->
<compilation defaultLanguage="vb" debug="true" />
<!-- CUSTOM ERROR MESSAGES
Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off"
to disable.
Add <error> tags for each of the errors you want to handle.
-->
<authentication mode="Windows" />
<!-- AUTHORIZATION
This section sets the authorization policies of the application. You can allow or
deny access to application resources by user or role. Wildcards: "*" mean everyone,
"?" means anonymous (unauthenticated) users.
-->
<authorization>
<allow users="*" /> <!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page within an application.
Set trace enabled="true" to enable application trace logging. If pageOutput="true",
the trace information will be displayed at the bottom of each page. Otherwise, you
can view the application trace log by browsing the "trace.axd" page from your web
application root.
-->
<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime"
localOnly="true" />
<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong to a particular
session. If cookies are not available, a session can be tracked by adding a session
identifier to the URL. To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false"
timeout="20"
/>
<!-- GLOBALIZATION
This section sets the globalization settings of the application.
-->
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>
</configuration>
|
Projectname.vsdisco
The Projectname.vsdisco (WebApplication1.vsdisco) file is an XML file that contains links
(URLs) to resources providing discovery information for an XML Web service. The .vsdisco
file looks as follows:
<?xml version="1.0" encoding="utf-8" ?>
<dynamicDiscovery xmlns="urn:schemas-dynamicdiscovery:disco.2000-03-17">
<exclude path="_vti_cnf" />
<exclude path="_vti_pvt" />
<exclude path="_vti_log" />
<exclude path="_vti_script" />
<exclude path="_vti_txt" />
<exclude path="Web References" />
</dynamicDiscovery
|
WebForm1.aspx, WebForm1.aspx.vb
The WebForm1.aspx file is the file with which you work. You design the interface
for your application, write
client-side scripts in this file. The WebForm1.aspx.vb file the code behind where
you write all the logic for the application that is processed back on the server.
|