探索自己实现页面基类.打造快速页面.
在很多时候。我门需要一种页面。这种页面不需要回送。为了速度。不需要使用服务器控件。必须保持高响应。他只要做动态显示。有不能做成静态页面。比如一些vip的文章显示。投票查看了。
webform框价功能强大。但是看看一个system.web.ui.page的源码。
[ToolboxItem(false), DesignerSerializer("Microsoft.VisualStudio.Web.WebForms.WebFormCodeDomSerializer, Microsoft.VisualStudio.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.Serialization.TypeCodeDomSerializer, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), DefaultEvent("Load"), Designer("Microsoft.VisualStudio.Web.WebForms.WebFormDesigner, Microsoft.VisualStudio.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(IRootDesigner)), DesignerCategory("ASPXCodeBehind"), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class Page : TemplateControl, IHttpHandler
{
// Events
[EditorBrowsable(EditorBrowsableState.Advanced)]
public event EventHandler InitComplete;
[EditorBrowsable(EditorBrowsableState.Advanced)]
public event EventHandler LoadComplete;
public event EventHandler PreInit;
[EditorBrowsable(EditorBrowsableState.Advanced)]
public event EventHandler PreLoad;
[EditorBrowsable(EditorBrowsableState.Advanced)]
public event EventHandler PreRenderComplete;
[EditorBrowsable(EditorBrowsableState.Advanced)]
public event EventHandler SaveStateComplete;
// Methods
static Page();
public Page();
[EditorBrowsable(EditorBrowsableState.Never)]
protected internal void AddContentTemplate(string templateName, ITemplate template);
public void AddOnPreRenderCompleteAsync(BeginEventHandler beginHandler, EndEventHandler endHandler);
public void AddOnPreRenderCompleteAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, object state);
[EditorBrowsable(EditorBrowsableState.Never)]
protected internal void AddWrappedFileDependencies(object virtualFileDependencies);
internal void ApplyControlSkin(Control ctrl);
internal bool ApplyControlStyleSheet(Control ctrl);
private void ApplyMasterPage();
[EditorBrowsable(EditorBrowsableState.Never)]
protected IAsyncResult AspCompatBeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData);
[EditorBrowsable(EditorBrowsableState.Never)]
protected void AspCompatEndProcessRequest(IAsyncResult result);
[EditorBrowsable(EditorBrowsableState.Never)]
protected IAsyncResult AsyncPageBeginProcessRequest(HttpContext context, AsyncCallback callback, object extraData);
[EditorBrowsable(EditorBrowsableState.Never)]
protected void AsyncPageEndProcessRequest(IAsyncResult result);
private void AsyncPageProcessRequestBeforeAsyncPointCancellableCallback(object state);
internal void BeginFormRender(HtmlTextWriter writer, string formUniqueID);
private void BuildPageProfileTree(bool enableViewState);
private void CheckRemainingAsyncTasks();
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected internal virtual HtmlTextWriter CreateHtmlTextWriter(TextWriter tw);
public static HtmlTextWriter CreateHtmlTextWriterFromType(TextWriter tw, Type writerType);
internal static HtmlTextWriter CreateHtmlTextWriterInternal(TextWriter tw, HttpRequest request);
internal IStateFormatter CreateStateFormatter();
private CultureInfo CultureFromUserLanguages(bool specific);
internal ICollection DecomposeViewStateIntoChunks();
internal static string DecryptString(string s);
[EditorBrowsable(EditorBrowsableState.Never)]
public void DesignerInitialize();
private bool DetermineIsExportingWebPart();
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected internal virtual NameValueCollection DeterminePostBackMode();
internal static string EncryptString(string s);
internal void EndFormRender(HtmlTextWriter writer, string formUniqueID);
public void ExecuteRegisteredAsyncTasks();
private void ExportWebPart(string exportedWebPartID);
public override Control FindControl(string id);
protected override void FrameworkInitialize();
internal NameValueCollection GetCollectionBasedOnMethod(bool dontReturnNull);
public object GetDataItem();
internal bool GetDesignModeInternal();
[EditorBrowsable(EditorBrowsableState.Advanced), Obsolete("The recommended alternative is ClientScript.GetPostBackEventReference. http://go.microsoft.com/fwlink/?linkid=14202")]
public string GetPostBackClientEvent(Control control, string argument);
[EditorBrowsable(EditorBrowsableState.Advanced), Obsolete("The recommended alternative is ClientScript.GetPostBackClientHyperlink. http://go.microsoft.com/fwlink/?linkid=14202")]
public string GetPostBackClientHyperlink(Control control, string argument);
[Obsolete("The recommended alternative is ClientScript.GetPostBackEventReference. http://go.microsoft.com/fwlink/?linkid=14202"), EditorBrowsable(EditorBrowsableState.Advanced)]
public string GetPostBackEventReference(Control control);
[Obsolete("The recommended alternative is ClientScript.GetPostBackEventReference. http://go.microsoft.com/fwlink/?linkid=14202"), EditorBrowsable(EditorBrowsableState.Advanced)]
public string GetPostBackEventReference(Control control, string argument);
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual int GetTypeHashCode();
internal override string GetUniqueIDPrefix();
public ValidatorCollection GetValidators(string validationGroup);
[EditorBrowsable(EditorBrowsableState.Never)]
protected object GetWrappedFileDependencies(string[] virtualFileDependencies);
private bool HandleError(Exception e);
protected virtual void InitializeCulture();
internal void InitializeStyleSheet();
private void InitializeThemes();
private void InitializeWriter(HtmlTextWriter writer);
[EditorBrowsable(EditorBrowsableState.Never)]
protected internal virtual void InitOutputCache(OutputCacheParameters cacheSettings);
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void InitOutputCache(int duration, string varyByHeader, string varyByCustom, OutputCacheLocation location, string varyByParam);
[Obsolete("The recommended alternative is ClientScript.IsClientScriptBlockRegistered(string key). http://go.microsoft.com/fwlink/?linkid=14202")]
public bool IsClientScriptBlockRegistered(string key);
[Obsolete("The recommended alternative is ClientScript.IsStartupScriptRegistered(string key). http://go.microsoft.com/fwlink/?linkid=14202")]
public bool IsStartupScriptRegistered(string key);
internal static bool IsSystemPostField(string field);
private void LoadAllState();
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected internal virtual object LoadPageStateFromPersistenceMedium();
internal void LoadScrollPosition();
public string MapPath(string virtualPath);
internal void OnFormPostRender();
internal void OnFormRender();
protected internal override void OnInit(EventArgs e);
protected virtual void OnInitComplete(EventArgs e);
protected virtual void OnLoadComplete(EventArgs e);
protected virtual void OnPreInit(EventArgs e);
protected virtual void OnPreLoad(EventArgs e);
protected virtual void OnPreRenderComplete(EventArgs e);
protected virtual void OnSaveStateComplete(EventArgs e);
private void PerformPreInit();
private void PerformPreRenderComplete();
internal void PopCachingControl();
internal void PopDataBindingContext();
private void PrepareCallback(string callbackControlID);
private void ProcessPostData(NameValueCollection postData, bool fBeforeLoad);
private void ProcessRequest();
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual void ProcessRequest(HttpContext context);
private void ProcessRequest(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint);
private void ProcessRequestCleanup();
private void ProcessRequestEndTrace();
private void ProcessRequestMain();
private void ProcessRequestMain(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint);
private void ProcessRequestTransacted();
[PermissionSet(SecurityAction.Assert, Unrestricted=true)]
private void ProcessRequestWithAssert(HttpContext context);
private void ProcessRequestWithNoAssert(HttpContext context);
internal void PushCachingControl(BasePartialCachingControl c);
internal void PushDataBindingContext(object dataItem);
internal void RaiseChangedEvents();
private void RaisePostBackEvent(NameValueCollection postData);
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void RaisePostBackEvent(IPostBackEventHandler sourceControl, string eventArgument);
[Obsolete("The recommended alternative is ClientScript.RegisterArrayDeclaration(string arrayName, string arrayValue). http://go.microsoft.com/fwlink/?linkid=14202"), EditorBrowsable(EditorBrowsableState.Advanced)]
public void RegisterArrayDeclaration(string arrayName, string arrayValue);
public void RegisterAsyncTask(PageAsyncTask task);
[Obsolete("The recommended alternative is ClientScript.RegisterClientScriptBlock(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202"), EditorBrowsable(EditorBrowsableState.Advanced)]
public virtual void RegisterClientScriptBlock(string key, string script);
internal void RegisterEnabledControl(Control control);
internal void RegisterFocusScript();
[EditorBrowsable(EditorBrowsableState.Advanced), Obsolete("The recommended alternative is ClientScript.RegisterHiddenField(string hiddenFieldName, string hiddenFieldInitialValue). http://go.microsoft.com/fwlink/?linkid=14202")]
public virtual void RegisterHiddenField(string hiddenFieldName, string hiddenFieldInitialValue);
[EditorBrowsable(EditorBrowsableState.Advanced), Obsolete("The recommended alternative is ClientScript.RegisterOnSubmitStatement(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202")]
public void RegisterOnSubmitStatement(string key, string script);
internal void RegisterPostBackScript();
internal void RegisterRequiresClearChildControlState(Control control);
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void RegisterRequiresControlState(Control control);
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void RegisterRequiresPostBack(Control control);
[EditorBrowsable(EditorBrowsableState.Advanced)]
public virtual void RegisterRequiresRaiseEvent(IPostBackEventHandler control);
public void RegisterRequiresViewStateEncryption();
[Obsolete("The recommended alternative is ClientScript.RegisterStartupScript(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202"), EditorBrowsable(EditorBrowsableState.Advanced)]
public virtual void RegisterStartupScript(string key, string script);
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void RegisterViewStateHandler();
internal void RegisterWebFormsScript();
protected internal override void Render(HtmlTextWriter writer);
private void RenderCallback();
private void RenderPostBackScript(HtmlTextWriter writer, string formUniqueID);
internal void RenderViewStateFields(HtmlTextWriter writer);
private void RenderWebFormsScript(HtmlTextWriter writer);
public bool RequiresControlState(Control control);
internal void ResetOnFormRenderCalled();
private void RestoreCultures(Thread currentThread, CultureInfo prevCulture, CultureInfo prevUICulture);
private void SaveAllState();
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected internal virtual void SavePageStateToPersistenceMedium(object state);
private void SetCulture(Thread currentThread, CultureInfo currentCulture, CultureInfo currentUICulture);
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal), SecurityPermission(SecurityAction.Assert, ControlThread=true)]
private void SetCultureWithAssert(Thread currentThread, CultureInfo currentCulture, CultureInfo currentUICulture);
public void SetFocus(string clientID);
public void SetFocus(Control control);
internal void SetForm(HtmlForm form);
internal void SetHeader(HtmlHead header);
private void SetIntrinsics(HttpContext context);
private void SetIntrinsics(HttpContext context, bool allowAsync);
internal void SetPreviousPage(Page previousPage);
internal void SetValidatorInvalidControlFocus(string clientID);
internal bool ShouldLoadControlState(Control control);
internal override void UnloadRecursive(bool dispose);
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void UnregisterRequiresControlState(Control control);
public virtual void Validate();
public virtual void Validate(string validationGroup);
[EditorBrowsable(EditorBrowsableState.Advanced)]
public virtual void VerifyRenderingInServerForm(Control control);
// Properties
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public HttpApplicationState Application { get; }
[EditorBrowsable(EditorBrowsableState.Never)]
protected bool AspCompatMode { get; set; }
[EditorBrowsable(EditorBrowsableState.Never)]
protected bool AsyncMode { get; set; }
[EditorBrowsable(EditorBrowsableState.Advanced), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public TimeSpan AsyncTimeout { get; set; }
internal Control AutoPostBackControl { get; set; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
public bool Buffer { get; set; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
public Cache Cache { get; }
internal string ClientOnSubmitEvent { get; }
public string ClientQueryString { get; }
public ClientScriptManager ClientScript { get; }
internal string ClientState { get; set; }
internal bool ClientSupportsFocus { get; }
internal bool ClientSupportsJavaScript { get; }
[DefaultValue(""), EditorBrowsable(EditorBrowsableState.Advanced), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), WebSysDescription("Page_ClientTarget"), Browsable(false)]
public string ClientTarget { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int CodePage { get; set; }
internal bool ContainsCrossPagePost { get; set; }
internal bool ContainsEncryptedViewState { get; set; }
internal bool ContainsTheme { get; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public string ContentType { get; set; }
protected internal override HttpContext Context { get; }
private StringSet ControlStateLoadedControlIds { get; }
[EditorBrowsable(EditorBrowsableState.Advanced), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string Culture { get; set; }
internal CultureInfo DynamicCulture { get; }
internal CultureInfo DynamicUICulture { get; }
private ArrayList EnabledControls { get; }
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DefaultValue(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual bool EnableEventValidation { get; set; }
[Browsable(false)]
public override bool EnableViewState { get; set; }
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool EnableViewStateMac { get; set; }
[WebSysDescription("Page_ErrorPage"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false), DefaultValue("")]
public string ErrorPage { get; set; }
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("The recommended alternative is HttpResponse.AddFileDependencies. http://go.microsoft.com/fwlink/?linkid=14202")]
protected ArrayList FileDependencies { set; }
internal Control FocusedControl { get; }
internal string FocusedControlID { get; }
public HtmlForm Form { get; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public HtmlHead Header { get; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override string ID { get; set; }
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual char IdSeparator { get; }
public bool IsAsync { get; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
public bool IsCallback { get; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsCrossPagePostBack { get; }
internal bool IsExportingWebPart { get; }
internal bool IsExportingWebPartShared { get; }
internal bool IsInAspCompatMode { get; }
internal bool IsInOnFormRender { get; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
public bool IsPostBack { get; }
internal bool IsPostBackEventControlRegistered { get; }
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public bool IsReusable { get; }
internal bool IsTransacted { get; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
public bool IsValid { get; }
[Browsable(false)]
public IDictionary Items { get; }
internal string LastFocusedControl { [AspNetHostingPermission(SecurityAction.Assert, Level=AspNetHostingPermissionLevel.Low)] get; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
public int LCID { get; set; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool MaintainScrollPositionOnPostBack { get; set; }
[WebSysDescription("MasterPage_MasterPage"), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public MasterPage Master { get; }
[WebSysDescription("MasterPage_MasterPageFile"), DefaultValue(""), WebCategory("Behavior")]
public virtual string MasterPageFile { get; set; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public int MaxPageStateFieldLength { get; set; }
public PageAdapter PageAdapter { get; }
protected virtual PageStatePersister PageStatePersister { get; }
internal Stack PartialCachingControlStack { get; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Page PreviousPage { get; }
internal string RelativeFilePath { get; }
internal bool RenderFocusScript { get; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public HttpRequest Request { get; }
internal HttpRequest RequestInternal { get; }
internal NameValueCollection RequestValueCollection { get; }
internal string RequestViewStateString { get; }
internal bool RequiresViewStateEncryptionInternal { get; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
public HttpResponse Response { get; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
public string ResponseEncoding { get; set; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
public HttpServerUtility Server { get; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual HttpSessionState Session { get; }
[Obsolete("The recommended alternative is Page.SetFocus and Page.MaintainScrollPositionOnPostBack. http://go.microsoft.com/fwlink/?linkid=14202"), Browsable(false), Filterable(false)]
public bool SmartNavigation { get; set; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false), Filterable(false)]
public virtual string StyleSheetTheme { get; set; }
internal bool SupportsStyleSheets { get; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
public virtual string Theme { get; set; }
[Localizable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Bindable(true)]
public string Title { get; set; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
public TraceContext Trace { get; }
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool TraceEnabled { get; set; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
public TraceMode TraceModeValue { get; set; }
[EditorBrowsable(EditorBrowsableState.Never)]
protected int TransactionMode { get; set; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Advanced), Browsable(false)]
public string UICulture { get; set; }
protected internal virtual string UniqueFilePathSuffix { get; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
public IPrincipal User { get; }
internal string ValidatorInvalidControl { get; }
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ValidatorCollection Validators { get; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DefaultValue(0), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ViewStateEncryptionMode ViewStateEncryptionMode { get; set; }
[Browsable(false)]
public string ViewStateUserKey { get; set; }
[Browsable(false)]
public override bool Visible { get; set; }
internal XhtmlConformanceMode XhtmlConformanceMode { get; }
// Fields
internal HttpApplicationState _application;
private bool _aspCompatMode;
private AspCompatApplicationStep _aspCompatStep;
private PageAsyncInfo _asyncInfo;
private bool _asyncMode;
private PageAsyncTaskManager _asyncTaskManager;
private TimeSpan _asyncTimeout;
private bool _asyncTimeoutSet;
private Control _autoPostBackControl;
internal Cache _cache;
private bool _cachedRequestViewState;
private ICallbackEventHandler _callbackControl;
private ArrayList _changedPostDataConsumers;
private string _clientQueryString;
private ClientScriptManager _clientScriptManager;
private string _clientState;
private bool _clientSupportsJavaScript;
private bool _clientSupportsJavaScriptChecked;
private string _clientTarget;
private bool _containsCrossPagePost;
private bool _containsEncryptedViewState;
private IDictionary _contentTemplateCollection;
internal HttpContext _context;
private ArrayList _controlsRequiringPostBack;
private StringSet _controlStateLoadedControlIds;
private Stack _dataBindingContext;
private bool _designMode;
private bool _designModeChecked;
private CultureInfo _dynamicCulture;
private CultureInfo _dynamicUICulture;
private ArrayList _enabledControls;
private bool _enableEventValidation;
private bool _enableViewStateMac;
private ViewStateEncryptionMode _encryptionMode;
internal string _errorPage;
private Control _focusedControl;
private string _focusedControlID;
private bool _fOnFormRenderCalled;
private HtmlForm _form;
private bool _fPageLayoutChanged;
private bool _fPostBackScriptRendered;
private bool _fRequirePostBackScript;
private bool _fRequireWebFormsScript;
private bool _fWebFormsScriptRendered;
private bool _haveIdSeparator;
private HtmlHead _header;
private char _idSeparator;
private bool _inOnFormRender;
private bool _isCallback;
private bool _isCrossPagePostBack;
private IDictionary _items;
private NameValueCollection _leftoverPostData;
private bool _maintainScrollPosition;
private MasterPage _master;
private VirtualPath _masterPageFile;
private int _maxPageStateFieldLength;
private bool _needToPersistViewState;
private PageAdapter _pageAdapter;
private SimpleBitVector32 _pageFlags;
private Stack _partialCachingControlStack;
private PageStatePersister _persister;
private bool _preInitWorkComplete;
private Page _previousPage;
private VirtualPath _previousPagePath;
private bool _profileTreeBuilt;
internal HybridDictionary _registeredControlsRequiringClearChildControlState;
internal ControlSet _registeredControlsRequiringControlState;
private ArrayList _registeredControlsThatRequirePostBack;
private IPostBackEventHandler _registeredControlThatRequireRaiseEvent;
private string _relativeFilePath;
internal HttpRequest _request;
private NameValueCollection _requestValueCollection;
private string _requestViewState;
private bool _requireFocusScript;
private bool _requireScrollScript;
internal HttpResponse _response;
private int _scrollPositionX;
private const string _scrollPositionXID = "__SCROLLPOSITIONX";
private int _scrollPositionY;
private const string _scrollPositionYID = "__SCROLLPOSITIONY";
private HttpSessionState _session;
private bool _sessionRetrieved;
private SmartNavigationSupport _smartNavSupport;
private PageTheme _styleSheet;
private string _styleSheetName;
private int _supportsStyleSheets;
private PageTheme _theme;
private string _themeName;
private string _titleToBeSet;
private int _transactionMode;
private string _uniqueFilePathSuffix;
private bool _validated;
private string _validatorInvalidControl;
private ValidatorCollection _validators;
private bool _viewStateEncryptionRequested;
private string _viewStateUserKey;
private XhtmlConformanceMode _xhtmlConformanceMode;
private bool _xhtmlConformanceModeSet;
internal const bool BufferDefault = true;
internal const string callbackID = "__CALLBACKID";
internal const string callbackIndexID = "__CALLBACKINDEX";
internal const string callbackLoadScriptID = "__CALLBACKLOADSCRIPT";
internal const string callbackParameterID = "__CALLBACKPARAM";
internal static readonly int DefaultAsyncTimeoutSeconds;
internal static readonly int DefaultMaxPageStateFieldLength;
private const string EnabledControlArray = "__enabledControlArray";
internal const bool EnableEventValidationDefault = true;
internal const bool EnableViewStateMacDefault = true;
internal const ViewStateEncryptionMode EncryptionModeDefault = ViewStateEncryptionMode.Auto;
internal static readonly object EventInitComplete;
internal static readonly object EventLoadComplete;
internal static readonly object EventPreInit;
internal static readonly object EventPreLoad;
internal static readonly object EventPreRenderComplete;
internal static readonly object EventSaveStateComplete;
internal const string EventValidationPrefixID = "__EVENTVALIDATION";
private static readonly Version FocusMinimumEcmaVersion;
private static readonly Version FocusMinimumJScriptVersion;
private const int isCrossPagePostRequest = 8;
private const int isExportingWebPart = 2;
private const int isExportingWebPartShared = 4;
private static readonly Version JavascriptMinimumVersion;
private const string lastFocusID = "__LASTFOCUS";
internal const bool MaintainScrollPositionOnPostBackDefault = false;
private static readonly Version MSDomScrollMinimumVersion;
private const string PageID = "__Page";
private const string PageReEnableControlsScriptKey = "PageReEnableControlsScript";
private const string PageRegisteredControlsThatRequirePostBackKey = "__ControlsRequirePostBackKey__";
private const string PageScrollPositionScriptKey = "PageScrollPositionScript";
private const string PageSubmitScriptKey = "PageSubmitScript";
[EditorBrowsable(EditorBrowsableState.Never)]
public const string postEventArgumentID = "__EVENTARGUMENT";
[EditorBrowsable(EditorBrowsableState.Never)]
public const string postEventSourceID = "__EVENTTARGET";
internal const string previousPageID = "__PREVIOUSPAGE";
private static StringSet s_systemPostFields;
private static char[] s_varySeparator;
internal const bool SmartNavigationDefault = false;
private const int styleSheetInitialized = 1;
internal const string systemPostFieldPrefix = "__";
private static readonly string UniqueFilePathSuffixID;
internal const string ViewStateEncryptionID = "__VIEWSTATEENCRYPTED";
internal const string ViewStateFieldCountID = "__VIEWSTATEFIELDCOUNT";
internal const string ViewStateFieldPrefixID = "__VIEWSTATE";
internal const string WebPartExportID = "__WEBPARTEXPORT";
// Nested Types
private class PageAsyncInfo
{
// Methods
internal PageAsyncInfo(Page page);
internal void AddHandler(BeginEventHandler beginHandler, EndEventHandler endHandler, object state);
internal void CallHandlers(bool onPageThread);
private void CallHandlersCancellableCallback(object state);
private void CallHandlersFromThreadpoolThread(object data);
private void CallHandlersPossiblyUnderLock(bool onPageThread);
private void OnAsyncHandlerCompletion(IAsyncResult ar);
internal void SetError(Exception error);
// Properties
internal bool AsyncPointReached { get; set; }
internal HttpAsyncResult AsyncResult { get; set; }
internal bool CallerIsBlocking { get; set; }
// Fields
private HttpApplication _app;
private bool _asyncPointReached;
private HttpAsyncResult _asyncResult;
private ArrayList _beginHandlers;
private bool _callerIsBlocking;
private WaitCallback _callHandlersCancellableCallback;
private WaitCallback _callHandlersThreadpoolCallback;
private bool _completed;
private AsyncCallback _completionCallback;
private int _currentHandler;
private ArrayList _endHandlers;
private Exception _error;
private int _handlerCount;
private Page _page;
private ArrayList _stateObjects;
private AspNetSynchronizationContext _syncContext;
}
}
不要忘记,*.cs内的类在继承了这个page类。最后*.aspx在编译成一个类 在继承*.cs内的类。 在编译*.aspx类的时候。会分析html字符串,把所有的html标签和文字写到类内。并用服务器控件的多少来分割他。最后建立一个控件树。
现在我门的思路是这样的 。想要用一个类来完全实现页面输出。这个类不需要继承system.web.ui.page。个人觉得在管道上切入不现实。最后选择在http处理程序上入手。所有的请求在进入http处理程序以后,检测访问路径。通过不同的路径去调用不同类的实例。不同类的内部在调用不同的模板。或者直接输出。直接产生输出结果。在http处理程序上返回。
我的想法是把处理工厂类封装起来。但是如何让所有的页面类在第一次访问前有一个实例,我想了好久,还是想不出好的办法。于是决定把处理工厂类开放出来。这样所有的问题就全解决。我们先在逻辑层定义一个处理工厂类
/**//// <summary>
/// 处理工厂类
/// </summary>
public sealed class TempletHandler : RunTimeTemplet, IHttpHandlerFactory, IRequiresSessionState
{
从接口继承。不需要修改这个函数#region 从接口继承。不需要修改这个函数
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
{
return RunTimeTemplet.HandlerFactory(url, this);
}
#endregion
为实现接口写上#region 为实现接口写上
public void ReleaseHandler(IHttpHandler handler)
{
}
#endregion
类文件和要显示页面匹配的函数。只要扩展这个函数就可以了。函数调用会自动进行#region 类文件和要显示页面匹配的函数。只要扩展这个函数就可以了。函数调用会自动进行
protected override BaseTempletHandler AddTempletClass(string FilePath)
{
BaseTempletHandler BackObject = null;
switch (FilePath)
{
case @"/WebSiteTest/Run/Test1.aspx": //要显示得文件可以是根本不存在得文件
BackObject = new CreatTempletHandler();
break;
case @"/WebSiteTest/Run/Test2.aspx": //对应第二个模板aa2.htm
BackObject = new SecendTempletHandler();
break;
case @"/WebSiteTest/Run/Test1.pdf":
BackObject = new CreatTempletHandler();
break;
case @"/WebSiteTest/Run/Test2.pdf":
BackObject = new SecendTempletHandler();
break;
default:
throw new Exception("错误:" + FilePath + "没有和任何一个类文件结合");
}
return BackObject;
}
#endregion
}
#endregion
TempletHandler 类就是开放在外的处理工厂类 ,下面我门在配置文件内注册他
<httpHandlers>
<add verb="*" path="Run/*.aspx" type="BusinessTest.TempletHandler,BusinessTest"/>
<add verb="*" path="Run/*.pdf" type="BusinessTest.TempletHandler,BusinessTest"/>
</httpHandlers>
表示在站点的run目录上所有的*.aspx文件和*.pdf文件全部转成我门的页面类处理。而实际上run目录上没有任何文件。
case @"/WebSiteTest/Run/Test1.aspx":
BackObject = new CreatTempletHandler();
这两句表示对/WebSiteTest/Run/Test1.aspx的请求 由CreatTempletHandler类处理。AddTempletClass函数一般只执行一次。在缓存没消失的情况下。他是不会被多次调用的。
CreatTempletHandler 类。他来全部负责/WebSiteTest/Run/Test1.aspx请求的输出。这种页面类只要继承BaseTempletHandler类就好了。页面布局你可以用模板来控制。显示你可以用标签来控制。当然要是想在提高速度。也可以不使用模板。并且不使用模板也绝对不会带来任何性能损失。
CreatTempletHandler,页面最终输出类的执行顺序是先是protected override void Page_Load(ref TempletReplet objILabel)函数执行。要是使用模板那在函数内部protected override void Page_Init(ref TempletReplet objILabel)函数被调用,记住Page_Init只执行一次。等Page_Load执行完毕以后 在执行其他的标签解析函数。最后 和成一个完整的页面输出。
public sealed class CreatTempletHandler : BaseTempletHandler
{
Page_Load事件函数#region Page_Load事件函数
protected override void Page_Load(ref TempletReplet objILabel)
{
获取变量,要是不使用模板完全可以忽略#region 获取变量,要是不使用模板完全可以忽略
if (HttpContext.Current.Request.QueryString.Count > 0)
{
this.PageId = HttpContext.Current.Request.QueryString[0];
}
else
{
this.PageId = "7";
}
this.UserId = "9";
System.Collections.Hashtable ht = new System.Collections.Hashtable();
ht.Add("PageId", this.PageId);
ht.Add("UserId", this.UserId);
DataSet ds = new DataSet();
ds.ReadXml(HttpContext.Current.Server.MapPath(@"/WebSiteTest/templet/BadWord.xml"));
sss objss = new sss();
objss.SS = "<font Color=red>信息载体类属性一</font>";
objss.SS1 = "<font Color=blue>信息载体类属性二.你好 我不是个稻草人</font>";
#endregion
使用模板部分,可以不使用#region 使用模板部分,可以不使用
objILabel = new CreatTempletHandler();
objILabel.ReadFilePath = HttpContext.Current.Server.MapPath(TempletFilePath);
objILabel.Obj = objss;
objILabel.LabelDatatable = ds.Tables[0];
objILabel.LabelHashtable = ht;
#endregion
}
#endregion
标签函数执行体#region 标签函数执行体
/**//// <summary>
/// 无参数函数 ((sss)this.Obj) 这样使用载体类
/// </summary>
/// <returns></returns>
public string show()
{
return "无参数标签执行结果" + ((sss)_this.Obj).SS + " " + ((sss)_this.Obj).SS1;
}
//一个参数函数
public string tag(string aa)
{
return "一个参数函数:" + aa;
}
//二个参数函数
public string tag_two(string aa, string bb)
{
return "二个参数函数:" + aa + " 和 " + bb;
}
public string Get_Test1()
{
return "你好我开始研究" + " " + ((sss)_this.Obj).SS1;
}
#endregion
标签,标签解析函数影射事件#region 标签,标签解析函数影射事件
/**//// <summary>
/// 标签,标签解析函数影射事件
/// </summary>
protected override void Page_Init(ref TempletReplet objILabel)
{
//如果要使用模板。那么写这个函数。要是不用模板,那么让这个函数为空就可以
CreatTempletHandler.AddLabel("无参书签", new Run_0(this.show), 0, ref objILabel);
CreatTempletHandler.AddLabel("第一个书签", new Run_0(this.Get_Test1), 0, ref objILabel);
CreatTempletHandler.AddLabel("一个参数书签", new Run_1(this.tag), 1, ref objILabel);
CreatTempletHandler.AddLabel("二个参数书签", new Run_2(this.tag_two), 2, ref objILabel); //好象这样就可以保留委托对象了 应为委托执行函数和委托是定义在一个类内
_this = objILabel;//如果要使用载体类,那么加这个语句。否则不需要加。其实不加这个理论上也可以使用载体类的。但我没测试
}
#endregion
public static string TempletFilePath = @"/WebSiteTest/templet/aa1.htm";//要指定的模板,当然不使用模板也完全可以
TempletReplet _this = null;//如果要使用载体类,那么加这个语句。否则不需要加,其实不加这个理论上也可以使用载体类的。但我没测试
//定义变量
string PageId, UserId;
}
#endregion
这种方法页面和一般的继承page类的页面那个快,那个节省资源我没有做具体测试。其实这就是动态程序集。和内存中的对象在合并字符串速度上的比较。用页面类。可以保证在高并发情况下安全性 。就是80,90个请求同时到达,返回的结果绝对不会互相冲突。但是我没有加上多线程。应为我现在也搞不清楚在aspx页面并发很高的情况下。多线程异步回调是发生在那。处理管道上有管道池。那异步回调是发生在管道上,还是http处理程序上,或者是http处理模块上。或者是*.aspx编译成的类上。以后我加上多线程。对方法异步回调。这样我相信页面类的处理能力将更强大。
下载代码:/Files/vitality2007/Show.rar