ProcessRequest() приватный Метод

private ProcessRequest ( HttpContext context ) : void
context HttpContext
Результат void
 public static IStateFormatter CreateFormatter()
 {
     HttpResponse response = new HttpResponse(TextWriter.Null);
     HttpRequest request = new HttpRequest("__token__.aspx", 
         HttpContext.Current.Request.Url.ToString(), "__EVENTTARGET=true&__VIEWSTATEENCRYPTED=true");
     HttpContext context = new HttpContext(request, response);
     
     Page page = new Page();
     page.EnableViewStateMac = true;
     page.ViewStateEncryptionMode = ViewStateEncryptionMode.Always;
     
     page.ProcessRequest(context);
     return new TokenPersister(page).StateFormatter;
 }
			public static Func<IStateFormatter> CreateFormatterGenerator(bool encrypt, bool sign)
			{
				TextWriter writer = TextWriter.Null;

				HttpResponse response = new HttpResponse(writer);
				HttpRequest request = new HttpRequest("wahha.aspx", HttpContext.Current.Request.Url.ToString(),
					"__EVENTTARGET=true" + ((encrypt) ? "&__VIEWSTATEENCRYPTED=true" : null));
				HttpContext context = new HttpContext(request, response);

				Page page = new Page() {
					EnableViewStateMac = sign,
					ViewStateEncryptionMode = (encrypt)
						? ViewStateEncryptionMode.Always
						: ViewStateEncryptionMode.Never
				};
				page.ProcessRequest(context);
				return () => new TokenPersister(page).StateFormatter;
			}
Пример #3
0
        private void page_lifecycle_test()
        {
            Page page = new Page();

              MockObject<HttpBrowserCapabilities> mockBrowser = MockManager.MockObject<HttpBrowserCapabilities>(Constructor.NotMocked);
              mockBrowser.ExpectGetAlways("PreferredRenderingMime", "text/html");
              mockBrowser.ExpectGetAlways("PreferredResponseEncoding", "UTF-8");
              mockBrowser.ExpectGetAlways("PreferredRequestEncoding", "UTF-8");
              mockBrowser.ExpectGetAlways("SupportsMaintainScrollPositionOnPostback", false);

              MockObject<HttpRequest> mockRequest = MockManager.MockObject<HttpRequest>(Constructor.Mocked);
              mockRequest.ExpectGetAlways("FilePath", "/default.aspx");
              mockRequest.ExpectGetAlways("HttpMethod", "GET");
              mockRequest.ExpectGetAlways("Browser", mockBrowser.Object);

              MockObject<HttpResponse> mockResponse = MockManager.MockObject<HttpResponse>(Constructor.Mocked);

              HttpContext mockContext = new HttpContext(mockRequest.Object, mockResponse.Object);

              using (StringWriter stringWriter = new StringWriter())
              using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
              {
            mockBrowser.AlwaysReturn("CreateHtmlTextWriter", htmlWriter);
            page.PreInit +=
              delegate(object sender, EventArgs e)
              {
            // Perform some action
              };
            page.Load +=
              delegate(object sender, EventArgs e)
              {
            // Check/Assert the results of your action
              };
            page.ProcessRequest(mockContext);
              }
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="ctr"></param>
		/// <param name="renderMode"></param>
		public static void CheckOnlyRenderSelf(Control ctr, ControlRenderMode renderMode)
		{
			if (renderMode.OnlyRenderSelf && renderMode.UseNewPage && ctr.Page.Items[PageExtension.PageRenderControlItemKey] != ctr)
			{
				Page currentPage = ctr.Page;
				ctr.Parent.Controls.GetType().GetMethod("SetCollectionReadOnly", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(ctr.Parent.Controls, new object[1] { null });

				Page page = new Page();

				PageRenderModePageCache currentPageCache = PageRenderModeHelper.GetPageRenderModeCache(currentPage);
				PageRenderModePageCache pageCache = PageRenderModeHelper.GetPageRenderModeCache(page);

				SetPageLevel(pageCache, GetPageLevel(currentPageCache) + 1);
				string currentPageUniqueID = GetPageUniqueID(currentPageCache);

				if (currentPageUniqueID != string.Empty)
					currentPageUniqueID += ",";

				SetPageUniqueID(pageCache, string.Format("{0}{1}", GetPageUniqueID(currentPageCache), ctr.UniqueID));

				page.AppRelativeVirtualPath = ctr.Page.AppRelativeVirtualPath;
				page.EnableEventValidation = false;

				InitNewPageContent(page, ctr);

				page.AttachPageModules();

				page.ProcessRequest(HttpContext.Current);

				HttpContext.Current.Response.End();
			}
		}
Пример #5
0
				public static Func<IStateFormatter> CreateFormatterGenerator()
				{
					// This code instantiates a page and tricks it into thinking that it's servicing
					// a postback scenario with encrypted ViewState, which is required to make the
					// StateFormatter properly decrypt data. Specifically, this code sets the
					// internal Page.ContainsEncryptedViewState flag.
					var writer = TextWriter.Null;
					var response = new HttpResponse(writer);
					var request = new HttpRequest("DummyFile.aspx", HttpContext.Current.Request.Url.ToString(), "__EVENTTARGET=true&__VIEWSTATEENCRYPTED=true");
					var context = new HttpContext(request, response);
					var page = new Page
					{
						EnableViewStateMac = true,
						ViewStateEncryptionMode = ViewStateEncryptionMode.Always
					};
					page.ProcessRequest(context);

					return () => new TokenPersister(page).StateFormatter;
				}
Пример #6
0
 /// <summary>
 /// Loads the specific page.
 /// </summary>
 /// <param name="page">The page which to load.</param>
 public static void Load(Page page)
 {
     HttpContext context = Http.Context;
     Http.ManuallyLoadedPage = page;
     page.ProcessRequest(Http.Context);
 }