DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Dnn MVC Module, null reference ex with Html.DisplayFor Tag

Sort:
You are not authorized to post a reply.





New Around Here





    Hello,

    I have recently been experiencing with dnn MVC module as i am intersted in moving from vb net  asp webform to C#  dnn Mvc for future module creation.

    However, i am having null reference exeption when i want to use @HtmlDisplayFor helper. Reading the doc, i did not see any unsupported mention about this helper.
    I would like to know why this is happening but i dont realy know where and what to look for in order to diagnose this.

    I am using Christoc MVC Module template generator, and my Test view look like this :

    As you can see, exception happens when view is generated and a displayfor tag helper is present. Swaping to no helper or a DisplayTextFor helper works without any problem.

    DemoItem class is pretty simple :


        [Cacheable("DemoItems", CacheItemPriority.Default, 20)]
        public class DemoItem
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public DateTime DateCreation { get; set; }
            public DateTime DateModification { get; set; }
        }

    Controller too :

    namespace Christoc.Modules.DNNModule1.Controllers
    {
        [DnnHandleError]
        public class DemoItemController : DnnController
        {
            // GET: DemoItem
            public ActionResult Index()
            {
                var demoItems = new List
                {
                    new DemoItem{Id = 1,Name = "DemoItem 1",DateCreation = DateTime.Now },
                    new DemoItem{Id = 2,Name = "DemoItem 2",DateCreation = DateTime.Now },
                    new DemoItem{Id = 3,Name = "DemoItem 3",DateCreation = DateTime.Now },
                    new DemoItem{Id = 4,Name = "DemoItem 4",DateCreation = DateTime.Now } 
                };

                var log = new EventLogController();
                log.AddLog("DemoMVC", "Index DemoItemController triggered", PortalSettings, User.UserID, EventLogController.EventLogType.ADMIN_ALERT);

                return View(demoItems);
            }

    }

    StackTrace :

    Ex.Message = Object reference not set to an instance of an object.
    Ex.Source = DotNetNuke.Web.Mvc
    Stacktrace =    at DotNetNuke.Web.Mvc.Framework.ModuleDelegatingViewEngine.RunAgainstModuleViewEngines(ControllerContext controllerContext, Func`2 engineRequest)
       at System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths)
       at System.Web.Mvc.ViewEngineCollection.FindPartialView(ControllerContext controllerContext, String partialViewName)
       at System.Web.Mvc.Html.TemplateHelpers.ExecuteTemplate(HtmlHelper html, ViewDataDictionary viewData, String templateName, DataBoundControlMode mode, GetViewNamesDelegate getViewNames, GetDefaultActionsDelegate getDefaultActions)
       at System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData, ExecuteTemplateDelegate executeTemplate)
       at System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData)
       at System.Web.Mvc.Html.TemplateHelpers.TemplateFor[TContainer,TValue](HtmlHelper`1 html, Expression`1 expression, String templateName, String htmlFieldName, DataBoundControlMode mode, Object additionalViewData)
       at System.Web.Mvc.Html.DisplayExtensions.DisplayFor[TModel,TValue](HtmlHelper`1 html, Expression`1 expression)
       at ASP._Page_DesktopModules_MVC_DNNModule1_Views_DemoItem_Index_cshtml.Execute() in c:\inetpub\wwwdnn\DesktopModules\MVC\DNNModule1\Views\DemoItem\Index.cshtml:line 21

    Any help or hints is welcome.






    Veteran Member





      Did you make any progress with this? Are you using the latest version of Chris's templates?
      Joe Craig
      DNN MVP
      Patapsco Research Group





      New Around Here





        Hi, i did not manage to solve the issue.
        Concerning Christoc module, i am using the lastest one (v 10.1)






        New Around Here





          Hi Leonard,

          Did you find a solution to this problem?
          I am experiencingthe same issue with Editor and EditorFor
           

          You are not authorized to post a reply.

          These Forums are dedicated to the discussion of DNN Platform.

          For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

          1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
          2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
          3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
          4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
          5. No Flaming or Trolling.
          6. No Profanity, Racism, or Prejudice.
          7. Site Moderators have the final word on approving / removing a thread or post or comment.
          8. English language posting only, please.

          Would you like to help us?

          Awesome! Simply post in the forums using the link below and we'll get you started.

          Get Involved