Try our conversational search powered by Generative AI!

Error on startpage

Vote:
 

I'm using step 3 of the getting started guide. Here I am able to see the start page in CMS edit mode but when I compile the application I get a 404 Error and the page tries to load http://localhost:18787/StartPage/Index I get an error on the index.cshtml page 

@using EPiServer.Core
@using EPiServer.Web.Mvc.Html

@model MyEPiServerSiteMVC.Models.Pages.StartPage

@Html.PropertyFor(m => m.mainbody)

Error105The type arguments for method 'EPiServer.Web.Mvc.Html.PropertyExtensions.PropertyFor(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.c:\Users\mcoleman\Documents\Visual Studio 2013\Projects\MyEPiServerSiteMVC\MyEPiServerSiteMVC\Views\StartPage\Index.cshtml74MyEPiServerSiteMVC

#121554
May 13, 2015 17:15
Vote:
 

You are trying to open the view directly and that does not work (visual studio will do that if you for example are having the view as the active document when pressing f5).

just remove the /StartPage/Index from the url and see what happens, hopefully everything will work (if you have set the startpage for the site)

#121555
May 13, 2015 18:02
Vote:
 

Launching the application from the project level I get a resource cannot be found. I am also still getting the exception on line 7 of my view. I see this in the editor.

here is the code from my startpage model.

using System;
using System.ComponentModel.DataAnnotations;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using EPiServer.SpecializedProperties;

namespace MyEPiServerSiteMVC.Models.Pages
{
    [ContentType(DisplayName = "StartPage", GUID = "a14d1a8e-b070-4732-851a-0254c1567b26", Description = "")]
    public class StartPage : PageData
    {
      
                [CultureSpecific]
                [Display(
                    Name = "Main body",
                    Description = "The main body will be shown in the main content area of the page, using the XHTML-editor you can insert for example text, images and tables.",
                    GroupName = SystemTabNames.Content,
                    Order = 1)]
                public virtual XhtmlString MainBody { get; set; }
         
    }
}
#121556
May 13, 2015 18:12
Vote:
 

Hi, I think you have a syntax error, you should not have lower cased your property. Instead of m.mainbody, you should have exactly the same property casing as defined on StartPage:

@Html.PropertyFor(m => m.MainBody)
#121559
May 13, 2015 18:52
Vote:
 

That did not clear the error. Incedently the propery is not showing up via intellisense. 

#121560
May 13, 2015 20:15
Vote:
 

That is strange, are you shore you have build the solution after adding the property?

Do you get the MainBody from intellicense when you are in the controller?

Can you show us how your controller looks like?

#121561
May 13, 2015 20:36
Vote:
 

Incidently I can edit the start page and clicking view on website returns this link http://localhost:18787/en/start/ and displays the page. However starting the project from the project level in Visual Studio renders this link http://localhost:18787/ Is there addtional configurating needed?

#121562
May 13, 2015 20:38
Vote:
 

I do get MainBody via intellisense in the controller using currentPage. Here is the controller.

using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using EPiServer;
using EPiServer.Core;
using EPiServer.Framework.DataAnnotations;
using EPiServer.Web.Mvc;
using MyEPiServerSiteMVC.Models.Pages;

namespace MyEPiServerSiteMVC.Controllers
{
    public class StartPageController : PageController<StartPage>
    {
        public ActionResult Index(StartPage currentPage)
        {
            /* Implementation of action. You can create your own view model class that you pass to the view or
             * you can pass the page type for simpler templates */
            
            return View(currentPage);
        }
    }
}
#121563
May 13, 2015 20:41
Vote:
 

I was able to figure it out. I went to the AdminConfig and Manage Websites. section and the pervious information I had stored was gone. I re-added my site info and now the start page opens on project build. Thank you for all your assistance.

#121565
May 13, 2015 21:00
Vote:
 

Great that it work!

hope you have a great time with the rest of the get started steps 

#121566
May 13, 2015 21:47
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.