As I mentioned in an earlier post, I needed to implement a subscription approach for a couple of company .text weblogs. Consequently I had to add a new page in the .text httphandling framework and understand what was being handled behind the http scenes. That said, this is still a view from 1000 feet and there's a lot more I hope to understand about the framework and ScottW's use of httphandling. This post is based on .text 0.94 release.
Before describing the process, a helpful thing to know is that the subscriber.aspx page does not really exist and is physically comprised of a Pagetemplate.ascx with other controls loaded via a skins.config file in the web project skins directory. I'll get to those.
1) Create a new PageType enum. PageType class located in Dottext.Components project. Optional. Can use “Other or Not Specified.“
2) Copy existing class from Dottext.WebUI.Pages project folder to same folder and name accordingly. To follow existing naming convention I named the page "BlogSubscriberPage.cs." The page does a trackback using the PageType enum.
3) Copy existing class from Dottext.WebUI.Handlers folder to same folder and name accordingly. To follow existing naming convention I named the page "BlogSubscriberPageHandler.cs." The page handles the BlogSubscriberPage.cs added in #2.
4a) Add control entry to Skins\[skinname]\Skin.config file located in the web project. In this example, for Dottext.WebUI.Pages.BlogSubscriberPage. The Skin.config entry looks like the following:
<SkinPage Name="Dottext.WebUI.Pages.BlogSubscriberPage">
<Controls>
<SkinItem ControlName="Subscriber.ascx" ParentControl="pageBody" CacheKey = "ControlPage" CacheTime = "30" />
</Controls>
</SkinPage>
4b) The control is added to the Placeholder ID in the PageTemplate.ascx page located in the same directory. The template page excerpt where the control is loaded looks like the following:
<div class="centercolumn">
<asp:PlaceHolder ID="pageBody" Runat="server" />
</div>
5) Create actual .ASCX control in web project Skins\[skinname]\Controls folder. My control file name is Subscriber.ascx. There is no code-behind file and it inherits from a class in the Dottext.WebUI.Controls namespace.
<%@ Control Language="c#" AutoEventWireup="false" Inherits="Dottext.WebUI.Controls.Subscriber" %>
6) Add code-behind for .ASCX in Dottext.WebUI.Controls folder. In the example: Subscriber.cs. It inherits from BaseControl class found in the same directory.
public class Subscriber : BaseControl
7) Add httphandler in web project blog.config file. This is what mine looks like:
<HttpHandler Pattern = "^(?:\/\w+\/\w+\/subscriber\.aspx)$" Type = "Dottext.WebUI.Pages.BlogSubscriberPageHandler, Dottext.WebUI" HandlerType = "Factory" />
I hope no corrections are required, though I certainly welcome them and any additional info on the process.
Happy .text coding!