Try our conversational search powered by Generative AI!

Warn if property is not set as virtual


If you create a pagetype with new properties it would be neat if we could get a clear indication or warning if the property isn't set as virtual in code = won't work.

That would save some debugging time in most projects. Is it visible in logs maybe already? I haven't checked. Possible to display in edit /admin?

Feb 25, 2016 22:00

To me, I get a quite good YSOD with detailed Exception message at site startup if I forget to make a property virtual. Don't you get that?

Don't remember if it only applies when I have the Display attributes though (which to me is essential to add)

Edited, Feb 25, 2016 22:42

I haven't tested it lately, it was a few years back now, but I know I forgot it earlier and just got null back. I saw an other user had the same problem the other day so it seems to still be a small problem sometimes...maybe tweak it a little then I guess :)

Feb 26, 2016 8:37


It is possible to define the following block:

[ContentType(GUID = "1F8B71EF-4776-4282-A8F0-45A6599FF06F")]
public class MyBlock : BlockData
    public ContentReference Image { get; set; }

Episerver won't throw any exception (ysod), and it will allow editors to store the value in edit mode.

In backend, Image is always null.

Apr 22, 2016 15:45

There is a bug in the validation if a property is part of an interface (because it is virtual but also final):

Tested the above code and it seems to throw now.

Sep 12, 2016 15:57
This thread is locked and should be used for reference only.
* 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.