Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Victoria 14 posts 114 karma points
    Oct 23, 2018 @ 22:42
    Victoria
    0

    Login Page Compilation Error

    Hi there,

    I'm just getting started in Umbraco and trying to create a login page.

    This is the login controller I've set up:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Umbraco.Web.Mvc;
    using Umbraco.Web.Models;
    
    namespace MyApp.Controllers
    {
        public class LoginController : SurfaceController
        {
        // GET: Login
            public ActionResult Login(LoginModel model)
            {
                if (!ModelState.IsValid)
                    return CurrentUmbracoPage();
    
                if (Members.Login(model.Username, model.Password))
                    return Redirect("/news");
    
                ModelState.AddModelError("", "Invalid Login");
                return CurrentUmbracoPage();
            }
        }
    }
    

    And this is the login partial view:

    @using MyApp.Controllers
    @model Umbraco.Web.Models.LoginModel
    
    @using (Html.BeginUmbracoForm<LoginController>("Login"))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)
    
        <fieldset>
            <div class="editor-label">
                @Html.LabelFor(model => model.Username)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Username)
                @Html.ValidationMessageFor(model => model.Username)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.Password)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Password)
                @Html.ValidationMessageFor(model => model.Password)
            </div>
        </fieldset>
    }
    

    I then created a login document type in Umbraco, a piece of content using that type (URL = '/login'), and created a login view and added my partial view to this:

    @inherits 
    Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Login>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
        Layout = null;
    }
    @Html.Partial("LoginPartial")
    

    When I try and navigate to '/login' I'm getting the following compilation error:

    Compiler Error Message: CS0234: The type or namespace name 'Login' does not exist in the namespace 'Umbraco.Web.PublishedContentModels' (are you missing an assembly reference?)

    Source Error:

    Line 40:
    Line 41:
    Line 42: public class PageViewsLogincshtml : Umbraco.Web.Mvc.UmbracoTemplatePage

    Just wondering what I might need to update in my templates?

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 24, 2018 @ 06:47
    Michaël Vanbrabandt
    0

    Hi Victoria,

    First of all welcome to the friendliest community of Umbraco!

    did you changed something to the web config for the Modelsbuilder or is this still the default?

    <add key="Umbraco.ModelsBuilder.ModelsMode" value="PureLive" />
    

    /Michaël

  • Victoria 14 posts 114 karma points
    Oct 24, 2018 @ 21:33
    Victoria
    0

    Hi Michaël,

    Thanks for the warm welcome! :)

    It's still using Pure Live for the models builder.

    Cheers,

    Victoria

Please Sign in or register to post replies

Write your reply to:

Draft