How login.cshtml file work

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
annachoi wrote:
Oh, i see.. I did what you had told me earlier, create another _LoginBox.cshtml in Views\Customer folder and found out index.cshtml is using _ColumnsThree.cshtml. So, i tried to add this into _ColumnsThree.cshtml.
@Html.Partial("_LoginBox", new Nop.Web.Models.Customer.LoginModel())

And I received this error stated InvalidOperationException was unhandled by user code.
The partial view '_LoginBox' was not found or no view engine supports the searched locations. The following locations were searched:

~/Themes/DefaultClean/Views/Home/_LoginBox.cshtml

~/Themes/DefaultClean/Views/Home/_LoginBox.vbhtml

~/Themes/DefaultClean/Views/Shared/_LoginBox.cshtml

~/Themes/DefaultClean/Views/Shared/_LoginBox.vbhtml

~/Views/Home/_LoginBox.cshtml

~/Views/Home/_LoginBox.vbhtml

~/Views/Shared/_LoginBox.cshtml

~/Views/Shared/_LoginBox.vbhtml

~/Administration/Views/Home/_LoginBox.cshtml

~/Administration/Views/Home/_LoginBox.vbhtml

~/Administration/Views/Shared/_LoginBox.cshtml

~/Administration/Views/Shared/_LoginBox.vbhtml


Put the _LoginBox.cshtml file either under /Home folder or /Shared folder. :D
11 years ago
And in my browser, states Server Error in '/' Application.
A public action method '_LoginBox' was not found on controller 'Nop.Web.Controllers.CustomerController'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A public action method '_LoginBox' was not found on controller 'Nop.Web.Controllers.CustomerController'.

Source Error:


Line 23:         <div class="clear">
Line 24:         </div>
Line 25:         @Html.Partial("_LoginBox", new Nop.Web.Models.Customer.LoginModel())
Line 26:         <div class="clear">
Line 27:         </div>

Source File: \\psf\home\Downloads\nopCommerce_2.80_Source\Presentation\Nop.Web\Views\Home\Index.cshtml    Line: 25

I really have no idea of what's happening right now and would appreciate very much if anybody can help me please..
11 years ago
annachoi wrote:
And in my browser, states Server Error in '/' Application.
A public action method '_LoginBox' was not found on controller 'Nop.Web.Controllers.CustomerController'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A public action method '_LoginBox' was not found on controller 'Nop.Web.Controllers.CustomerController'.

Source Error:


Line 23:         <div class="clear">
Line 24:         </div>
Line 25:         @Html.Partial("_LoginBox", new Nop.Web.Models.Customer.LoginModel())
Line 26:         <div class="clear">
Line 27:         </div>

Source File: \\psf\home\Downloads\nopCommerce_2.80_Source\Presentation\Nop.Web\Views\Home\Index.cshtml    Line: 25

I really have no idea of what's happening right now and would appreciate very much if anybody can help me please..


How does your _LoginBox.cshtml look like? Did you change to Html.BeginForm("Login", "Customer")? :D
11 years ago
Thanks alot for your prompt response and this is how  _LoginBox.cshtml file and I put it under Nop.Web\Home folder ya..
@{
    ViewBag.Title = "_LoginBox";
}

<h2>_LoginBox</h2>
@model LoginModel
@using Nop.Web.Models.Customer;
@using Nop.Core;
@using Nop.Core.Infrastructure;
@using Nop.Core.Infrastructure.DependencyManagement;
<h2>@ViewBag.Message</h2>
@{
    var registerUrl = Url.RouteUrl("Login");
    if (!String.IsNullOrEmpty(this.Context.Request.QueryString["returnUrl"]))
    {
        var webHelper = EngineContext.Current.Resolve<IWebHelper>();
        registerUrl = webHelper.ModifyQueryString(registerUrl, "returnurl=" + HttpUtility.UrlEncode(this.Context.Request.QueryString["returnUrl"]), null);
    }
}
<div class="block block-loginbox">
    <div class="title">
        <strong>@T("Login")</strong>
    </div>
    <div class="clear">
    </div>
<div class="listbox">
    <fieldset class="form-fields returning-wrapper">
            <legend>@T("Account.Login.ReturningCustomer")</legend>
            <dl>
                @using (Html.BeginForm("Login","Customer"))
                {
                    <dd class="message-error">
                        @Html.ValidationSummary(true, T("Account.Login.Unsuccessful").Text)
                    </dd>
                    
                    
                    <dt>
                        @Html.LabelFor(m => m.Email): </dt>
                    <dd>
                        @Html.TextBoxFor(m => m.Email, new { @class = "email", autofocus = "autofocus" })
                        @Html.ValidationMessageFor(m => m.Email)
                    </dd>
                    
                    <dt>
                        @Html.LabelFor(m => m.Password): </dt>
                    <dd>
                        @Html.PasswordFor(m => m.Password, new { @class = "password" })
                        @Html.ValidationMessageFor(m => m.Password)
                    </dd>
                    <dd>
                        @Html.CheckBoxFor(m => m.RememberMe)
                        @Html.LabelFor(m => m.RememberMe)
                    </dd>
                    <dd class="forgot-password">
                        @Html.RouteLink(T("Account.Login.ForgotPassword").Text, "PasswordRecovery")
                    </dd>
                  
                    <dd class="buttons">
                        <input class="button-1 login-button" type="submit" onclick="location.href='@registerUrl'" value="@T("Account.Login.LoginButton")" />
                    </dd>
                      
                }
            </dl>
        </fieldset>
        <div class="clear">
        </div>

     </div>
     </div>
11 years ago
Ahhh.. finally, it's working..thank you so much for your help wooncherk =)
11 years ago
annachoi wrote:
Ahhh.. finally, it's working..thank you so much for your help wooncherk =)


No problem! :D
11 years ago
I overided it completly and changed the whole system (with help) by implementing the Login Logic into the Index Controller but I cant give much as I have signed an agreement :) with my previous company.

But what I can say Implement the Login Logic to the Index controller, right click the action create your view with your HTML etc
Then place it in the ColunmShared3.cshtml. Just Change it..

Also

http://www.asp.net/mvc

Btw that was with 2.4

Take Care :D
11 years ago
i want it too.
please vote -
https://nopcommerce.codeplex.com/workitem/11434

Shay
11 years ago
shayt wrote:
i want it too.
please vote -
https://nopcommerce.codeplex.com/workitem/11434

Shay


Actually it isn't that hard anyway. No modification of Controller is needed actually. I have quickly written a blog post about this, hopefully it will help you! :)

Displaying Log In Box at the Home Page (or Any Other Pages)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.