Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Page with new page type from code can not be displayed

Vote:
 

Hi,

I use EpiServer CMS version 10 and Web Forms.

I have created a page type in my code and I also have created a page for this page type.

When I start my webapplication EpiServer finds my new page type and I can see it in the CMS admin mode.

But when I create a new page with this page type I get an ArgumentNullException when I try to display it.

This line returns null.

UrlResolver.Current.GetUrl(content.ContentLink)

Episerver's databas table tblContentType has null in column Filename for my new page type. Other pages that work, seems to have a filename here and if I set this value manually it works fine. Shouldn't that value be set when Episerver scans for new page types?

My code looks like this:

namespace Portal.Epi.Structure.PageTypes.Vma
{
    [TemplateDescriptor(
        Path = "/Templates/Pages/Vma/VmaTemplate.aspx")]
    [ContentType(
        GUID = "340e80f7-75d6-41f3-9629-d0c1ea501164",
        DisplayName = "Abc...",
        Description = "Abc...",
        Order = 1100,
        AvailableInEditMode = true)]
    public class VmaPage : BasePageData
    {
    }
}


namespace Portal.Epi.Templates.Pages.Vma
{
    [TemplateDescriptor(Path = "~/Templates/Pages/Vma/VmaTemplate.aspx")]
    public partial class VmaTemplate : BasePage<VmaPage>
    {
       ......
    }
}

Thanks!

#216589
Feb 10, 2020 16:35
Vote:
 

Have you published the page yet? If not, publish it and that should fix it. 

#216591
Feb 10, 2020 16:42
Vote:
 

Thanks for your answer!

Yes, but it doesn't help.

Should the Filename in databasetable tblContentType be set when you publish a page?

#216596
Edited, Feb 10, 2020 16:54
Vote:
 

The filename in tblcontenttype should/might be set when Episerver discover that you have created or updated a new content type not when publishing a page.

Regarding that GetUrl is returning null it feels more like that the content is not related to any view engine but in your code it looks like it should have.

Try go to admin and into the content type and reset it to default so it is not problem with someone made changes in admin that is overriding your code

#216914
Feb 11, 2020 7:18
Vote:
 

Thanks, Henrik!

I run this on my own local environment, so no one else has access to it.

But I did try to reset it to default, but  same result.

#216919
Feb 11, 2020 8:02
Vote:
 

Hmm, strange, must miss something
The problem is that all examples now is MVC (https://world.episerver.com/documentation/developer-guides/CMS/rendering/templatedescriptor-and-tags/)

Compare it with those that works (in code) and see if you have missed something

#216920
Feb 11, 2020 8:15
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.