HttpHandler is wrong.

Topics: Developer Forum, Project Management Forum, User Forum
Nov 19, 2008 at 3:57 AM
/// <summary>Infuses the http handler (usually an aspx page) with the content page associated with the url if it implements the <see cref="IContentTemplate"/> interface.</summary>
        public void InjectContentPage()
            IContentTemplate template = webContext.Handler as IContentTemplate;
            if (template != null)
                template.CurrentItem = webContext.CurrentPage;

As I watch the requests go through N2CMS, I see that the handler correctly represents the view of the content item being requested.

For example, when requesting a TextPage, the IContentTemplate is {ASP.templates_ui_views_text_aspx} and so on for sitemap, news..  everything. This is correct as the TemplateUrl is being used correctly.

I have added a new project. Add the N2 and N2.Template references to it, built a AbstractBlogPage the inherits from AbstractContentPage and overrides the TemplateUrl to match the addon/blog set of parts and views. When I publish to the wwroot (N2.Templates), the contentItem "Blog" (which inherits from AbstractBlogPage) shows up when I try to create a new page. Works great here. When I request the new blog page I created, I get a "Unable to cast type Blog to LanguageRoot". I looked in the debugger and saw that the IContentTemplate was the type of {ASP.default_aspx}. It should be {ASP.addons_blogenginenet_ui_views_blog_aspx}.

Where do you think the problem is?

Should I package up my project (really small with no dependencies besides N2 and N2.Tempaltes) and send it to you?

Nov 19, 2008 at 4:40 AM
Another thing worth mentioning...

In my AbstractBlogPage, I have removed the TemplateUrl override and in the Blog class, I have overrided the TemplateName to "Text".

No I am getting the expected cast error of {Blog} and {TextPage}. Here at least the IContentTemplate is returning the {ASP.templates_ui_views_text_aspx} rather than {ASP.default_aspx}.

Im not thinking the problem lies within my small addon library.
Nov 19, 2008 at 6:13 PM
I renamed the view page to Blog2 and changed the TemplateName on the Blog content item and it works. choked on the name "Blog". why is that?
Nov 19, 2008 at 9:10 PM
That's strange. I can take a look if you send the kodez.
Nov 20, 2008 at 2:51 AM