Sei sulla pagina 1di 2

Visual Web Developer 2005 Express Edition

Cheat Sheet : ASP.NET Basics


ASP.NET Special Folders Markup and Code in a Single File
Bin Contains assemblies used by the web application

App_Code C# or VB source code that is common to the web site.


Utility classes, modules BasePages etc.

App_Data SQLExpress databases used by the web site.

App_GlobalResources Resources shared across all pages and controls.

App_LocalResources Resources specific to a page or control

App_WebReferences References to web services


Markup and Code in Separate Files. "code behind model"
App_Themes Contains .skin, .css and image files used for the themes of the site. <%@ Page Language="C#" ClassName="Page1_aspx" Inherits="Page1" CodeFile="Page1.aspx.cs" %>
App_Browsers Optional .browser capabilities files.

Common Page and Control Directives


<%@ Page Language="C#" %>
<%@ Page Language="VB" %>
<%@ Page Language="C#" CodeFile="Page1.ascx.cs" Inherits="Control1" %>
<%@ Page Language="VB" CodeFile="Page1.ascx.vb" Inherits="Control1" %>

<%@ Control Language="C#" %>


<%@ Control Language="VB" %>
<%@ Control Language="C#" CodeFile="Page1.ascx.cs" Inherits="Control1" %>
<%@ Control Language="VB" CodeFile="Page1.ascx.vb" Inherits="Control1" %>

<%@ Register TagPrefix="uc1" TagName="Control1" Src="Control1.ascx" %>


<%@ Register TagPrefix="lvs" Namespace="Lvs.Web.UI" Assembly="Lvs.Web" %>

<%@ Import Namespace="System.Data" %>

<%@ OutputCache Duration="60" VaryByParam="none" %>


<%@ OutputCache Location="Server" VaryByParam="param1;param2" Duration="60" %>
<%@ OutputCache Location="None" NoStore="true" %>

Code Blocks Resources


Strings.resx Strings.es-MX.resx
Inline code block <% Response.Write("Hello World"); %>

Inline render block <%= string.Format("2+2={0}", 2+2); %>

Data binding <%# Container.ItemIndex %>


expression block protected void Page_Load(object sender, EventArgs e)
{
Expression block <%$ Resources:String, Hello %> Label1.Text=Resources.Strings.Hello;
}

Page level code. Methods, <script runat="server"></script> <asp:Label ID="Label1" Text="<%$ Resources:Strings, Hello %>" runat="server" />
properties, variable and
event handlers.
Default.aspx.resx Default.aspx.es-MX.resx

<asp:Label ID="Label2" meta:resourceskey="HelloLabel" runat="server" />


www.LearnVisualStudio.NET
Copyright © 2006, LearnVisualStudio.NET
Visual Web Developer 2005 Express Edition
Cheat Sheet : Common Web.config Settings
App Settings Custom Error Pages Providers
<appSettings> <customeErrors mode="RemoteOnly" <membership>
<add key="MyKey" value="MyValue" /> <customeErrors defaultRedirect="MyErrorPage.htm"> <providers>
</appSettings> <error statusCode="403" redirect="NoAccess.htm" /> <clear />
<error statusCode="404" redirect="FileNotFound.htm" /> <add
</customErrors> name="AspNetSqlMembershipProvider"
Connection Strings type="System.Web.Security.SqlMembershipProvider,
<connectionStrings> type="System.Web,
<add Default Settings for Pages type="Version=2.0.0.0,
name="LocalSqlServer" type="Culture-neutral,
connectionString=" <pages type="PublicKeyToken=b03f5f7f11d50a3a"
data source=.\SQLEXPRESS; theme="MyTheme" connectionStringName="LocalSqlServer"
Integrated Security=SSPI; styleSheetTheme="MyTheme" enablePasswordRetrieval="false"
AttachDBFilename=|DataDirectory|aspnetdb.mdf; autoEventWireup="true" enablePasswordReset="true"
User Instance=true" masterPageFile="MyMaster" requiresQuestionAndAnswer="true"
providerName="System.Data.SqlClient" pageBaseType="MyBasePage" applicationName="/"
/> userControlBaseType="MyBaseControl" requiresUniqueEmail="false"
</connectionStrings> > passwordFormat="Hashed"
<controls> maxInvalidPasswordAttempt="5"
<add tagPrefix="uc" minRequiredPasswordLength="7"
Authentication <add tagName="MyControl" minRequiredNonalphanumericCharacters="1"
<authentication mode="Windows" /> <add src="~/Controls/MyControl1.ascx" /> passwordAttemptWindow="10"
<add tagPrefix="pfx" passwordStrengthRegularExpression=""
<authentication mode="Forms"> <add tagName="MyAssembly" />
<forms <add src="My.Namespace" /> </providers>
loginUrl="Login.aspx" </controls> </membership>
defautUrl="Page1.aspx" <namespaces>
cookieless="AutoDetect" <add namespace="System.Text" /> <profile>
domain="mydomain.com" </namespaces> <providers>
requireSSL="true" </pages> <clear />
/> <add
</authentication> name="AspNetSqlProfileProvider"
connectionStringName="LocalSqlServer"
applicationName="/"
Authorization type="System.Web.Profile.SqlProfileProvider,
<authorization> type"=System.Web,
<!-- Deny anonymous users --> type"=Version=2.0.0.0,
<deny users="?" /> type"=Culture-neutral,
<!-- Allow all authed users --> type="PublicKeyToken=b03f5f7f11d50a3a"
<allow users="*" /> </providers>
<!-- Allow admin role --> </profile>
<allow roles="Admin" />
</authorization> <roleManager>
<providers>
<clear />
<add
name="AspNetSqlRoleProvider"
connectionStringName="LocalSqlServer"
applicationName="/"
type="System.Web.Profile.SqlRoleProvider,
type="System.Web,
type="Version=2.0.0.0,
type="Culture-neutral,
type="PublicKeyToken=b03f5f7f11d50a3a"
</providers>
</roleManager>

www.LearnVisualStudio.NET
Copyright © 2006, LearnVisualStudio.NET

Potrebbero piacerti anche