SaaS CMS has officially launched! Learn more now.

How to add a form in _Root.cshtml


I need to add a small form with a textfield for email and login button, in the site header in the _Root.cshtml. 

I tried to post from it to an action defined in the StartPageController, but it doesn't work, I get 404. What the best way to implement this?

using (Html.BeginForm("Login", "StartPageController", FormMethod.Post))
    <input required="required" type="text" id="loginHint" name="loginHint" value="" placeholder="Enter email">
    <button id="loginBtn" class="btn" type="submit">Login</button>
Mar 23, 2021 12:55

I think "StartPage" instead of "StartPageController"...?

using (Html.BeginForm("Login", "StartPage", FormMethod.Post))
Mar 23, 2021 13:55
Helani Wanniarachchi - Mar 24, 2021 5:37
Still the same, getting 404.


Add Route using the initialization module and give it a try

    public class MVCRoutesInitializationModule : IInitializableModule
        public void Initialize(InitializationEngine context)

        private void MapRoutes(RouteCollection routes)
            routes.MapRoute(null, "login", new { controller = "StartPage", action = "Login" });

        public void Uninitialize(InitializationEngine context)
            //Add uninitialization logic
Mar 24, 2021 12:52
Helani Wanniarachchi - Mar 25, 2021 10:21
Yes, it worked. Thanks
Ravindra S. Rathore - Mar 25, 2021 10:22
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.