H
Hope Paka
I want to use my custom url extension instead of .aspx. I can achieve this
by writing a custom handler that implements the IHttpHandlerFactory.
In the GetHandler method of the IHttpHandlerFactory i want to construct a
Page class instance and load my other controls to it and return the page
instance.
This is what .net framework does. There is a small difference what i am
thinking and the .net framework has done. .Net Framework calls the
PageParser.GetCompiledPageInstance() methot to take the page from the cached
content. In my implemention, instance of the Page class is created and it is
returned.
Ex:
PageHandlerFactory
public virtual IHttpHandler GetHandler(HttpContext context, string
requestType, string url, string path)
{
InternalSecurityPermissions.UnmanagedCode.Assert();
return PageParser.GetCompiledPageInstanceInternal(url, path, context);
}
<add verb="*" path="*.umut" type="MyOwnHandlerFactory"/>
MyOwnHandlerFactory
public virtual IHttpHandler GetHandler(HttpContext context, string
requestType, string url, string path)
{
Page page = new Page
page.Controls.Add ( new System.Web.UI.LiteralControl
("<html><head></head><body>");
System.Web.UI.HtmlControls.HtmlForm form = new
System.Web.UI.HtmlControls.HtmlForm ()
form.Name = "Form1";
form.Method = "Post";
page.Controls.Add (form);
Control c1 = page.LoadControl (ABC.ascx);
form.Controls.Add (c1);
page.Controls.Add ( new System.Web.UI.LiteralControl ("</body><html>");
return page.
}
I have described what the .net framework does and the one in my mind. I am
still using the framework but only i have different extension.
As a summary:
1) Do i loose the cache functionality of the PageParser. (May be it is
not necessary because i am only parsing UserControls with page.LoadControl)
2) Can i use everthing that asp.net supports like Session, ViewState
etc?
by writing a custom handler that implements the IHttpHandlerFactory.
In the GetHandler method of the IHttpHandlerFactory i want to construct a
Page class instance and load my other controls to it and return the page
instance.
This is what .net framework does. There is a small difference what i am
thinking and the .net framework has done. .Net Framework calls the
PageParser.GetCompiledPageInstance() methot to take the page from the cached
content. In my implemention, instance of the Page class is created and it is
returned.
Ex:
PageHandlerFactory
public virtual IHttpHandler GetHandler(HttpContext context, string
requestType, string url, string path)
{
InternalSecurityPermissions.UnmanagedCode.Assert();
return PageParser.GetCompiledPageInstanceInternal(url, path, context);
}
<add verb="*" path="*.umut" type="MyOwnHandlerFactory"/>
MyOwnHandlerFactory
public virtual IHttpHandler GetHandler(HttpContext context, string
requestType, string url, string path)
{
Page page = new Page
page.Controls.Add ( new System.Web.UI.LiteralControl
("<html><head></head><body>");
System.Web.UI.HtmlControls.HtmlForm form = new
System.Web.UI.HtmlControls.HtmlForm ()
form.Name = "Form1";
form.Method = "Post";
page.Controls.Add (form);
Control c1 = page.LoadControl (ABC.ascx);
form.Controls.Add (c1);
page.Controls.Add ( new System.Web.UI.LiteralControl ("</body><html>");
return page.
}
I have described what the .net framework does and the one in my mind. I am
still using the framework but only i have different extension.
As a summary:
1) Do i loose the cache functionality of the PageParser. (May be it is
not necessary because i am only parsing UserControls with page.LoadControl)
2) Can i use everthing that asp.net supports like Session, ViewState
etc?