How is the ASP.NET page generated?

zhaozj2021-02-16  62

Using system;

Namespace WebApp3 {Using System.io; Using System.Web; Using System.collections; Using System.collections.Specialization;

Class mypage: system.Web.ui.templateControl, System.Web.ihttphandler {public void processRequest (httpContext context) {this.setIntrins (constext); this.ProcessRequest ();}

#region SetIntrinsics private void SetIntrinsics (HttpContext context) {this._context = context; this._request = context.Request; this._response = context.Response; this._application = context.Application; this._cache = context.Cache; if ((this._clienttarget! = null) && (this._clientTarget.length> 0)) {// this._request.clientTarget = this._clientTarget;} // base.hookupautomaticHandlers ();} #ENDREGION

#region ProcessRequest private void ProcessRequest () {// Thread thread1 = Thread.CurrentThread; // CultureInfo info1 = thread1.CurrentCulture; // CultureInfo info2 = thread1.CurrentUICulture; FrameworkInitialize (); try {try {// if (this. Istransacted) // {// this.ProcessRequestTransacted (); ///} // {this.ProcessRequestMain (); //} // this.ProcessRequestendTrace (); return;} finally {// this. ProcessRequestCleanup (); // InternalSecurityPermissions.ControlThread.Assert (); // thread1.CurrentCulture = info1; // thread1.CurrentUICulture = info2;} // return;} catch // (object obj1) {throw;}} #endregion

private void ProcessRequestMain () {HttpContext context1; // Exception exception1; try {this._requestValueCollection = this.DeterminePostBackMode (); context1 = base.Context; // if (context1.TraceIsEnabled) // {this.Trace.Write ( " Asp.page "," begin init "); //} // base.initrecurs (null); initrecurs (null); // if (context1.traceisenable) // {this.trace.write (" aspx.page " , "End init"); //} if (this.ispostback) {// if (context1.traceisenable) // {this.trace.write ("aspx.page", "begin loadViewState); //} This .LoadPageViewState (); // if (context1.traceisenable) // {this.trace.write ("aspx.page", "end loadviewstate); this.trace.write (" aspx.page "," begin processpostdata " ); //} // this.ProcessPostData (this._requestvaluecollection, true); // if (context1.traceisenable) // {this.trace.write ("asp.page", "End Proce SSPOSTDATA "); //}} // base.loadrecurs (); if (this.ispostback) {// {this.traceisenable (" asp.page "," begin processpostdata second Try "); //} // this.processpostdata (this._leftoverpostdata, false); // if (context1.traceisenable) // {this.trace.write (" asp.page "," End ProcessPostData SECOND TRY ") This.Trace.write ("aspx.page", "begin raise changeevents"); //} // this.raiseChangeDevents ();

// {THIS.TRACE.WRITE ("ASPX.PAGE", "End Raise ChangeDevents"); this.trace.write ("aspx.page", "begin raise postbackevent"); / /} // this.raisePostBackevent (this._requestValueCollection); // if (context1.traceisenable) // {this.trace.write ("aspx.page", "end raise postbackevent"); ///}} // if (Context1.Traceisenable) // {this.trace.write ("aspx.page", "begin prerender"); //} // base.prerenderRecursiveInternal (); prerenderrecursInternal ();

// if (context1.traceisenabled) // {this.trace.write ("aspx.page", "end prerender"); base.buildprofiletree ("root", base.enableviewstate; this.trace.write ("ASPX .page "," Begin SaveViewState "); //} This.savePageViewState (); // if (context1.traceisenable) // {this.trace.write (" aspx.page "," end saveviewstate "; this. TRACE.WRITE ("aspx.page"); //} Base.RenderControl (this.createHtmlTextWriter (this.Response.output); // if (!! "{// Return ; ///} // this.trace.write ("aspx.page", "end render"); return;} // catch (threadabortexception exception) // {// base.unloadRecursive (TRUE); // Return; // /} // catch (configurationException exception3) // {// throw; // //} catCH / * (Exception exception1 = Exception4; // perfcounters.incrementer (AppperfCounter) Errors _DURING_REQUEST); // perfcounters.incrementCounter (AppPerfCounter.errors_total); // if (this.handleError (Exception1)) // {// Return; ////} // throw; // Return;}}

INTERNAL VOID PrerenderRecursiveInternal () {// String text1; // int Num1; // int Num2; // IF (this.flags [16] == null) // {// this.ensurechildControls (); // this. OnPrender (Eventargs.empty); // if (this._controls! = Null) // {// text1 = this._controls.setCollectionReadonly ("parent_collections_readonly"); // Num1 = this._Controls.count; // for Num2 = 0; (Num2

Protected Virtual HTMLTextWriter CreateHtmlTextWriter (TextWriter TW) {Return Null; // page.createHtmlTextWriterinternal (tw, this._request);}

protected override void FrameworkInitialize () {this .__ BuildControlTree (this); // this.FileDependencies = ASP.TestControls_aspx .__ fileDependencies; // this.EnableViewStateMac = true; // this.Request.ValidateInput ();} private void __BuildControlTree (System .Web.UI.Control __ctrl) {this .__ BuildControlform1 (); // System.Web.UI.IParserAccessor __parser = ((System.Web.UI.IParserAccessor) (__ ctrl)); // // __parser.AddParsedSubObject (this .form1); // // __parser.addparsedSubObject (new system.web.ui.literalcontrol ("/ r / n"));}

private System.Web.UI.Control __BuildControlform1 () {System.Web.UI.HtmlControls.HtmlForm __ctrl; __ctrl = new System.Web.UI.HtmlControls.HtmlForm (); this.form1 = __ctrl; __ctrl.ID = "form1 "; System.web.ui.iparseseraccessor __parser = ((system.web.ui.iparseraccessor) (__ ctrl)); __parser.AddParsedSubObject (new System.Web.UI.LiteralControl ( "/ r / n")); this .__ BuildControlButton1 (); // __parser.AddParsedSubObject (this.Button1); __parser.AddParsedSubObject (new System.Web.UI. LITERALCONTROL ("/ r / n")));

// this .__ buildControlDataGrid1 (); __parser.addparsedSubObject (this.dataGrid1); __parser.addparsedSubObject (new system.web.ui.literalcontrol ("/ r / n")); return__ctrl;}

private System.Web.UI.Control __BuildControlButton1 () {System.Web.UI.WebControls.Button __ctrl; __ctrl = new System.Web.UI.WebControls.Button (); // this.Button1 = __ctrl; __ctrl.ID = "Button1"; __ctrl.text = "button1"; // __ctrl.click = new system.eventhandler (this.button_click); Return __ctrl;}

INTERNAL VOID INITRECURSIVE (Control NamingContainer) {// string text1; // int Num1; // int Num2; // Control Control1; // i (this._controls! = null) // {// i (this.flags [ 128]! = Null) // {// NamingContainer = this; ///} // text1 = this._controls.setCollectionReadonly ("parent_collections_readonly"); // Num1 = this._Controls.count; // for (Num2 = 0; (NUM2

internal void LoadPageViewState () {// string text1; Triplet triplet1 = null; // = ((Triplet) this.LoadPageStateFromPersistenceMedium ()); // if (! triplet1 = null) // {// text1 = ((string) triplet1.First); // int.Parse (text1, NumberFormatInfo.InvariantInfo); // this._fPageLayoutChanged = (int.Parse (text1, NumberFormatInfo.InvariantInfo) = this.GetTypeHashCode ());! if (this._fPageLayoutChanged! ) {// base.LoadViewStateRecursive (triplet1.Second); this._controlsRequiringPostBack = ((ArrayList) triplet1.Third);} //}} protected virtual NameValueCollection DeterminePostBackMode () {if (base.Context.Request == null) { Return null;} // if (base.context.serverexecutedepth> 0) // {// Return Null; ////} // namevalueCollection Collection1 = this.getCollectionBaseDonMethod (); //iff ((Collection1 ["__ viewstate ] == NULL) && (Collection1 ["__ evenettarget"] == null)) // {// collection1 = null; // //} return null; // collection1;

Public bool isreusable {get {returnaf false;}}

Public TraceContext Trace {Get {Return Base.Context.trace;

}

}

Public Bool IsPostback {get {ix (this._requestvaluecollection == NULL) {Return False ;;} Return! THIS._FPAGELAYOUTCHANGED;}}

Public httpresponse response {get {if (this._response == null) {// throw new httpexception ("response_not_available"));} Return this._response;}}

// Fields internal HttpApplicationState _application; // private bool _aspCompatMode; // private AspCompatApplicationStep _aspCompatStep; internal System.Web.Caching.Cache _cache; // private ArrayList _changedPostDataConsumers; private string _clientTarget; internal HttpContext _context; private ArrayList _controlsRequiringPostBack; // private bool _enableViewStateMac; // internal string _errorPage; // private bool _fOnFormRenderCalled; private System.Web.UI.HtmlControls.HtmlForm _form; // private LosFormatter _formatter; private bool _fPageLayoutChanged; // private bool _fPostBackScriptRendered; // private bool _fRequirePostBackScript; / / private bool _inOnFormRender; // private NameValueCollection _leftoverPostData; private bool _needToPersistViewState; // private IDictionary _registeredArrayDeclares; // private IDictionary _registeredClientScriptBlocks; // private IDictionary _registeredClientStartupScripts; // private ArrayList _registeredContr olsThatRequirePostBack; // private IPostBackEventHandler _registeredControlThatRequireRaiseEvent; // private IDictionary _registeredHiddenFields; // private IDictionary _registeredOnSubmitStatements; internal HttpRequest _request; private NameValueCollection _requestValueCollection; internal HttpResponse _response; // private System.Web.SessionState.HttpSessionState _session; // private bool _sessionRetrieved; // private SmartNavigationSupport _smartNavSupport; // private int _transactionMode; // private bool _validated; // private ValidatorCollection _validators; // private object _viewStateToPersist; // private string _viewStateUserKey; private const string clientScriptEnd = "// -> / r / N

"; Private const string clientscriptstart ="