11. 弌舒于仆亠仆亳亠 WebForms 亳 MVC
o Incoming HTTP Request
o ApplicationManager
o HttpApplication
o Global.asax
o Modules (IHttpModule)
o UrlRoutingModule
o IIS 7.0
26. 亠仗舒亳亠仄 ASP.NET : DLR
o IronPython.dll
o IronPython.Modules.dll
o Microsoft.Scripting.dll
o Microsoft.Scripting.Core.dll
o Microsoft.Web.Scripting.dll
27. 亠仗舒亳亠仄 ASP.NET : DLR
<httpModules>
<add name="DynamicLanguageHttpModule"
type="Microsoft.Web.Scripting.DynamicLanguageHttpModule"/>
</httpModules>
28. 亠仗舒亳亠仄 ASP.NET : DLR
Internal class DynamicLanguageHttpModule : IHttpModule,
IBuildProvider
{
private class GlobalAsaxBuildResult :
TypeWithEventsBuildResult
{
private void CallFunction(ScriptEngine engine,
DynamicFunction f)
{
f.Invoke(engine, new object[0]);
}
}
}
30. 亠仗舒亳亠仄 ASP.NET : BP
o 仂亳 仂 BuilderProvider 仂 David Ebbo
http://blogs.msdn.com/davidebb/archive/2
009/06/01/a-buildprovider-to-simplify-
your-asp-net-mvc-action-links.aspx
31. 亠仗舒亳亠仄 ASP.NET : BP
<%= Html.ActionLink("Home", "Index", "Home")%>
public ActionResult Test(int id, string name)
{
return View();
}
<%= Html.ActionLink("Test Link", "Test", "Home",
new { id = 17, name = "David" }, null) %>
32. 亠仗舒亳亠仄 ASP.NET : BP
<%= Html.ActionLinkToHomeIndex("Home")%>
<%= Html.ActionLinkToHomeTest("Test Link", 17,
"David")%>
<buildProviders>
<add extension=".actions束
type="MvcActionLinkHelper.MvcActionLinkBuildPro
vider" />
</buildProviders>
33. 亠仗舒亳亠仄 ASP.NET : BP
<%= Html.ActionLink<HomeController>(c => c.Index(),
"Home")%>
ASP.NET MVC 2 Beta Futures
http://aspnet.codeplex.com/Release/ProjectReleases.aspx?R
eleaseId=36054
34. 亠仗舒亳亠仄 ASP.NET : BP
o 200 仂从 从仂亟舒
o 仂仍从仂 舒弍仂 CodeDom
o 2 从仂仄仄亠仆舒亳 HACK
o 亠从仂仍从仂 从仂仄仄亠仆舒亳亠于 束 仂亢舒仍亠仆亳
仆亠仍亰β
35. 亠仗舒亳亠仄 ASP.NET : BP
o 亠亠亟亠仍舒仆仂 仆舒 T4
o 仂仂舒 亠舒仍亳亰舒亳亳 亳 仂仗仂于仂亢亟亠仆亳
o 亠仂弍仂亟亳仄仂 仗亠亠从仂仄仗亳仍亳亳 仗亳
于从仍舒亟于舒仆亳亳 仆舒 亠于亠
44. 亟亠亠 ASP.NET 4.0
Auto-Start Web Applications
public class CustomInitialization :
System.Web.Hosting.IProcessHostPreloadClient
{
public void Preload(string[] parameters)
{
// Perform initialization.
}
}
45. 亟亠亠 ASP.NET 4.0
Permanently Redirecting a Page (301)
RedirectPermanent("/newpath/foroldcontent.aspx");
46. 亟亠亠 ASP.NET 4.0
The Incredible Shrinking Session State
<sessionState
mode="SqlServer"
sqlConnectionString="data source=dbserver;Initial
Catalog=aspnetstate"
allowCustomSqlDatabase="true"
compressionEnabled="true"/>
Compression with System.IO.Compression.GZipStream
47. 亟亠亠 ASP.NET 4.0
Expanding the Range of Allowable URLs
In previous versions 260 characters (based on NTFS)
<httpRuntime maxRequestPathLength="260"
maxQueryStringLength="2048" />
<httpRuntime requestPathInvalidChars=""<,>,*,%,&,:," />
48. 亟亠亠 ASP.NET 4.0
Extensible Request Validation
<httpRuntime requestValidationType="Samples.MyValidator,
Samples" />
public class CustomRequestValidation : RequestValidator
{
protected override bool IsValidRequestString(
HttpContext context, string value,
RequestValidationSource requestValidationSource,
string collectionKey,
out int validationFailureIndex) {...}
}
50. 亟亠亠 ASP.NET 4.0
Object Caching Extensibility
private void btnGet_Click(object sender, EventArgs e)
{
ObjectCache cache = MemoryCache.Default;
fileContents = cache["filecontents"] as string;
if (fileContents == null)
{
CacheItemPolicy policy = new CacheItemPolicy();
List<string> filePaths = new List<string>();
filePaths.Add("c:data.txt");
policy.ChangeMonitors.Add(new HostFileChangeMonitor(filePaths));
fileContents = File.ReadAllText("c:data.txt");
cache.Set("filecontents", fileContents, policy);
}
MessageBox.Show(fileContents);
}
51. 亟亠亠 ASP.NET 4.0
HTML, URL, and HTTP Header Encoding
System.Web.Util.HttpEncoder
System.Web.HttpUtility
System.Web.HttpServerUtility
<httpRuntime
encoderType="Samples.MyCustomEnco
der, Samples" />
52. 亟亠亠 ASP.NET 4.0
Performance Monitoring for Individual
Applications in a Single Worker Process
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<runtime>
<appDomainResourceMonitoring
enabled="true"/>
</runtime>
</configuration>
58. 亟亠亠 ASP.NET 4.0
Script Loader
o MicrosoftAjaxComponentModel.js
o MicrosoftAjaxCore.js
o MicrosoftAjaxGlobalization.js
o ACTCommon.js
o ACTExtenderBase.js
o ACTWatermark.js
59. 亟亠亠 ASP.NET 4.0
Content Delivery Network
<script src=/slideshow/the-old-new-aspnet/2653966/"ajax.microsoft.com/ajax/0910/start.js"></script>
http://www.asp.net/ajaxlibrary/cdn
60. 亟亠亠 ASP.NET 4.0
Client Data Access
o Client data controls
o Client templates
o Client data context
62. 亟亠亠 ASP.NET 4.0
Client Data Access : DataView
<h1>Movies</h1>
<ul id="moviesView">
<li>{{Title}} - {{Director}}</li>
</ul>
63. 亟亠亠 ASP.NET 4.0
Client Data Access : DataView
o ASP.NET (.asmx) Web services.
o WCF Web services.
o ADO.NET Data Services.
o Anything that returns JSON-formatted data.
64. 亟亠亠 ASP.NET 4.0
Client DataContext, AdoNetDataContext
仂仂亢亳 仆舒:
o LINQ to SQL DataContext
o Entity Framework ObjectContext
仂亟亟亠亢亳于舒ム:
o 丼亠仆亳亠 亳 亰舒仗亳
o 仂亟亟亠亢亳于舒亠 仍仂亢仆亠 于磶亳 亳
舒仂亳舒亳亳
69. 亟亠亠 ASP.NET 4.0
Browser Capabilities Providers
o 仂弍舒于仍亠仆 仆仂于亠 仂仗亳舒仆亳
o 亠亠仂仗亠亟亠仍磳仄亶 仗仂于舒亶亟亠
70. 亟亠亠 ASP.NET 4.0
Routing
http://website/products.aspx?categoryid=12
http://website/products/software
o 舒亰仂于亶 从仍舒: PageRouteHandler
o 弌于仂亶于舒: Page.RouteData
71. 亟亠亠 ASP.NET 4.0
Routing
public class Global : System.Web.HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapPageRoute("SearchRoute",
"search/{searchterm}", "~/search.aspx");
RouteTable.Routes.MapPageRoute("UserRoute",
"users/{username}", "~/users.aspx");
}
82. 亟亠亠 ASP.NET 4.0
QueryExtender Control :
CustomExpression
<asp:LinqDataSource ID="dataSource" runat="server"
TableName="Products">
</asp:LinqDataSource>
<asp:QueryExtender TargetControlID="dataSource" runat="server">
<asp:CustomExpression OnQuerying="FilterProducts" />
</asp:QueryExtender>
83. 亟亠亠 ASP.NET 4.0
QueryExtender Control :
CustomExpression
protected void FilterProducts(object sender, CustomExpressionEventArgs
e)
{
e.Query = from p in e.Query.Cast<Product>()
where p.UnitPrice >= 10
select p;
}
84. 亟亠亠 ASP.NET 4.0
Html Encoded Code Expressions
<%: expression %>
<%= HttpUtility.HtmlEncode(expression) %>
<%: Request["UserInput"] %>
IHtmlString
<%: new HtmlString("<strong>HTML that is not encoded</strong>") %>
85. 亟亠亠 ASP.NET 4.0
VS: Project Template Changes
o Empty Web Application Template
o Web Application & Web Site Project
Templates
87. 亠
o In depth: The ASP.NET MVC Pipeline
http://blog.codeville.net/2007/11/20/aspn
et-mvc-pipeline-lifecycle/
o Comparing Web Forms And ASP.NET MVC
http://msdn.microsoft.com/en-
us/magazine/dd942833.aspx
o ASP.NET Application Life Cycle Overview
for IIS 7.0 http://msdn.microsoft.com/en-
us/library/bb470252(VS.100).aspx
88. 亠
o ASP.NET on CodePlex
http://aspnet.codeplex.com/
o ASP.NET 4 and Visual Studio 2010 Web
Development Beta 2 Overview
http://www.asp.net/LEARN/whitepapers/as
pnet4/default.aspx