public void InitPageObject() { if(IncomingHTTPRequest.SortedHeaders.ContainsKey("HOST")) { //Console.WriteLine("--test: " + IncomingHTTPRequest.SortedHeaders["HOST"].ToUpper()); //Console.WriteLine("--test: " + this.HostName.ToUpper()); if(1 == 1 || IncomingHTTPRequest.SortedHeaders["HOST"].ToUpper() == this.HostName.ToUpper()) { int catid = GetCatID(IncomingHTTPRequest.Parts[0]); if(catid < 0) { Console.WriteLine("CatID: {0} {1}", catid, IncomingHTTPRequest.Parts[0]); PageObject = new gurumod.WebPages.Home(); } else { //Console.WriteLine("CatID: {0}", catid); try { PageObject = (WebPages.WebPage)Activator.CreateInstance(Type.GetType(Categories[catid].ObjectType)); } catch(Exception ex) { Console.WriteLine("btEngine: WebInterface: Invalid type spec on creating a page."); Console.WriteLine(ex.Message); PageObject = new gurumod.WebPages.Home(); } } } else { // The hostname specified does not match up. if(RedirectOtherHostNames) { PageObject = new gurumod.WebPages.StatusCodes.MovedPermanently(); PageObject.OutgoingHeaders = "Location: http://" + this.HostName + "/" + IncomingHTTPRequest.RequestLine; Console.WriteLine("btEngine: WebInterface: HostNameFilter: " + PageObject.OutgoingHeaders); Console.WriteLine(" && " + this.HostName + " :: " + IncomingHTTPRequest.SortedHeaders["HOST"]); } else { PageObject = new gurumod.WebPages.Home(); } } } else { // The request didn't specify a hostname, so let's // redirect to the main hostname. PageObject = new gurumod.WebPages.StatusCodes.MovedPermanently(); PageObject.OutgoingHeaders = "Location: http://" + this.HostName + "/" + IncomingHTTPRequest.RequestLine; } PageObject.UserID = UserID; //PageObject.CurrentUser = this.CurrentUser; PageObject.InHeaders = this.IncomingHTTPRequest.Headers; PageObject.RequestParts = IncomingHTTPRequest.Parts; PageObject.IncomingContent = this.IncomingContent; PageObject.PostVars = this.IncomingHTTPRequest.PostVars; PageObject.Run(); }
public bool RunSubPage(WebPage wp) { wp.IncomingContent = IncomingContent; wp.InHeaders = InHeaders; wp.PostVars = PostVars; wp.RequestParts = RequestParts; wp.TerminateOnSend = TerminateOnSend; wp.Run(); TerminateOnSend = wp.TerminateOnSend; OutgoingBuffer = wp.OutgoingBuffer; OutgoingByteBuffer = wp.OutgoingByteBuffer; OutgoingHeaders = wp.OutgoingHeaders; ContentType = wp.ContentType; UseAsciiOutput = wp.UseAsciiOutput; return true; }