SaaS CMS has officially launched! Learn more now.

Custom login page


So I am trying to create a custom login page instead of the EPi Server. Right now I have created a custom controller and model and page using this tutoiral

The thing is when I type http://localhost:53067/LoginPage/Index in the browser window I get null for the currenPage in the below code

        public ActionResult Index(LoginPage currentPage, [FromUri]string ReturnUrl)
            /* 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 */

            var model = new LoginModel(currentPage);
            model.LoginPostbackData.ReturnUrl = ReturnUrl;

            return View(model);

Does anyone know what am I missing here?

Oct 31, 2017 13:02

You need to have a URL Epi can route to a page data object that you've added to the page tree.

If LoginPage is a Epi page type you need to use a URL of such a page.

Something like http://localhost:53067/my-cool-login-page/

Nov 17, 2017 17:48

I'm having the same problem. I'm a complete epi newbie except for an intensive boot camp training. 

I've created a login page, viewmodel, controller and view according to this article

Can you explain what you mean in the first sentence of your answer? How do I add my page to the page tree?  And how do I know what my page is called? Isn't is just login? 

Here's the definition of my login page:

[ContentType(DisplayName = "LoginPage", GUID = "a1c77b97-95a6-447d-af9a-4b79b8770040", Description = "Login Page")]
[AvailableContentTypes(Availability = Availability.Specific,
IncludeOn = new[] { typeof(StartPage) },
ExcludeOn = new[] { typeof(ContainerPage), typeof(ProductPage), typeof(StandardPage), typeof(ISearchPage), typeof(LandingPage) })]
public class LoginPage : StandardPage


Thanks for your help.

Feb 06, 2018 4:42
  1. Go to Edit mode.
  2. Add a new page of type "Login Page" below your start page.
  3. Check which URL it got.
  4. Set that URL, something like /en/my-login-page/ as the default login page in web.config.

This setup has some drawbacks since you need to set public access for that page you added, it not you will cause a redirect loop. Use /util/login.aspx as a backdoor if this has happend.

Feb 06, 2018 7:41

Thanks for your help. That did the trick!

Feb 06, 2018 23:11

The above solution assumes that your login page has a specific name-in-url set. To avoid that dependency you can do something like this.

In Global.asax.cs:

protected override void RegisterRoutes(RouteCollection routes)
    // login page route
    routes.MapRoute("Login", "login", new { Controller = "SignIn", action = "Index" });

In SignInPageController:

public override ActionResult Index(SignInPage currentPage)
    // if you come here from custom route and are missing currentPage
    if (currentPage == null)
        currentPage = PageHelper.SiteSettingsPage.SignInPage.Get<SignInPage>();

    var model _signInPageFactory.Service.Create(currentPage);
    return View("Index", model);

However, you will need to have some kind of global site config where you reference your Login page so you can fetch it programatically.

Sep 25, 2019 11:38
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.