΢ÈíÆóÒµ¿â5.0ѧϰ±Ê¼Ç£¨10£©ASP.NETÄ£¿éÒÀÀµ×¢Èë
Äú¿ÉÒÔʹÓÃHTTPÄ£¿é£¬Ò»¸öµ½ASP.NET HttpApplicationStateÀàµÄÀ©Õ¹£¬ÔÚGlobal.asax±àд´úÂëÇ¿ÖÆASP.NETÔÚÿһ¸öÒ³ÃæÇëÇóʱ×Ô¶¯×¢ÈëÒÀÀµµÄ¶ÔÏ󣬾ÍÏñÔÚASP.NET Web´°ÌåÓ¦ÓóÌÐòÖÐÌÖÂÛµÄÒ»Ñù.
ÏÂÁз½·¨ÏÔʾÁËÒ»¸öºÏÊʵķ½·¨Äܹ»»ñÈ¡PreRequestHandlerExecuteʼþ½«Ëü×Ô¼º×¢Èëµ½ASP.NETµÄÖ´ÐÐÁ÷Ë®Ïߣ¬ÔÚÿ¸öÒ³ÃæÇëÇóÖÐͨ¹ýÈÝÆ÷µÄBuildUp·½·¨ÔËÐÐHttpÄ£¿é£¬²¢»ñÈ¡OnPageInitCompleteʼþ¡£µ±OnPageInitCompleteÖ´ÐÐʱģ¿é´úÂë°´ÕÕËùÓеĿؼþÊ÷ÔËÐУ¬²¢Í¨¹ýÈÝÆ÷µÄBuildUp·½·¨´¦Àíÿ¸ö¿Ø¼þ¡£
BuildUp·½·¨»ñÈ¡ÒѾ´æÔڵĶÔÏóʵÀý£¬´¦Àí²¢Ìî³äÀàµÄÒÀÀµ£¬·µ»ØʵÀý¡£Èç¹ûûÓÐÒÀÀµÔò·µ»Ø×î³õµÄʵÀý¡£
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using Microsoft.Practices.Unity;
namespace Unity.Web
{
public class UnityHttpModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += OnPreRequestHandlerExecute;
}
public void Dispose() { }
private void OnPreRequestHandlerExecute(object sender, EventArgs e)
{
IHttpHandler currentHandler = HttpContext.Current.Handler;
HttpContext.Current.Application.GetContainer().BuildUp(
currentHandler.GetType(), currentHandler);
// User Controls are ready to be built up after page initialization is complete
var currentPage = HttpContext.Current.Handler as Page;
if (currentPage != null)
{
currentPage.InitComplete += OnPageInitComplete;
}
}
// Build up each control in the page's control tree
private void OnPageInitComplete(object sender, EventArgs e)
{
var currentPage = (Page)sender;
IUnityContainer container = HttpContext.Current.Application.GetContainer();
foreach (Control c in GetControlTree(currentPage))
{
container.BuildUp(c.GetType(), c);
}
context.PreRequestHandlerExecute -= OnPreRequestHandlerExecute;
}
// Ge
Ïà¹ØÎĵµ£º
Ò»£¬Ç°ÑÔ
CookiesÏë±ØËùÓÐÈ˶¼Á˽⣬ µ«ÊÇδ±ØËùÓÐÈ˶¼¾«Í¨¡£±¾ÎĽ²½âÁËCookiesµÄ¸÷·½Ãæ֪ʶ£¬ ²¢ÇÒÌá³öÀ´ÁË×î¼Ñʵ¼ù¡£ÕâÊDZÊÕßÔÚÈÕ³£¹¤×÷ÖеĻýÀۺͳÁµí¡£
¶þ£¬»ù´¡ÖªÊ¶
1.ʲôÊÇCookies
Cookie ÊÇһС¶ÎÎı¾ÐÅÏ¢£¬°éËæ×ÅÓû§ÇëÇóºÍÒ³ÃæÔÚ Web ·þÎñÆ÷ºÍä¯ÀÀÆ÷Ö®¼ä´«µÝ¡£Cookie °üº¬Ã¿´ÎÓû§·ÃÎÊÕ¾µãʱ Web Ó¦ÓóÌÐò¶¼¿ ......
protected void Page_Load(object sender, EventArgs e)
{
}
#region OnPreInit µÚÒ»²½
protected override void OnPreInit(EventArgs e)
{
//¼ì²é ......
+++ HiddenField01.aspxÒ³Ãæ
++ Ò³Ãæ´úÂëÈçÏ£º
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:HiddenField ID="HiddenField2" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
++ ºǫ́´úÂ룬ÈçÏ£º
protected void Button1_C ......
ASP.NET AJAXÈëÃÅϵÁн«»áд¹ØÓÚASP.NET AJAXһЩ¿Ø¼þµÄʹÓ÷½·¨ÒÔ¼°»ù´¡ÖªÊ¶£¬ÆäÖв¿·ÖÎÄÕÂΪԴ´£¬Ò²ÓÐһЩÎÄÕÂÊÇÖ±½Ó·Òë×Ô¹Ù·½Îĵµ£¬±¾²¿·ÖÄÚÈݻ᲻¶Ï¸üС£
Ŀ¼
ASP.NET AJAXÈëÃÅϵÁУ¨1£©£º¸ÅÊö
µ¼¶Á£º×÷Ϊ±¾ÏµÁÐÎÄÕµĿªÆª£¬¼òµ¥½éÉÜÒ»ÏÂASP.NET AJAXµÄ¸Å¿ö¼°¸÷¸ö×é³É²¿·Ö¡£
......