Override Existing Controller Action (Login & Register) in Nopcommerce Version 4.10

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
i need override customer controller login to add sms verification and mobile login in my plugin
when i write following code in my plugin RouteProvider.cs

   
public void RegisterRoutes(IRouteBuilder routeBuilder)
        {
            routeBuilder.MapLocalizedRoute("CustomLogin",
                "Login/",
                new { controller = "CustomCustomer", action = "Login" },
                new { },
                new[] { "WebPooye.Plugins.SMS.WpSMS.Controllers" }
            );
        }
        public int Priority
        {
            get { return int.MaxValue; }
        }


i have this exception :
An unhandled exception occurred while processing the request.
InvalidOperationException: The view 'Login' was not found. The following locations were searched:
/Themes/DefaultClean/Views/CustomCustomer/Login.cshtml
/Themes/DefaultClean/Views/Shared/Login.cshtml
/Views/CustomCustomer/Login.cshtml
/Views/Shared/Login.cshtml
/Pages/Shared/Login.cshtml

and when i write this :

public void RegisterRoutes(IRouteBuilder routeBuilder)
        {

            routeBuilder.MapLocalizedRoute("CustomLogin",
                "Login/",
                new { controller = "CustomCustomer", action = "Login" },
                new[] { "WebPooye.Plugins.SMS.WpSMS.Controllers" }
            );
        }
        public int Priority
        {
            get { return int.MaxValue; }
        }


i have this error :

An error occurred while starting the application.
RouteCreationException: The constraint entry 'Length' - '1' on the route 'Login/' must have a string value or be of a type which implements 'Microsoft.AspNetCore.Routing.IRouteConstraint'.
Microsoft.AspNetCore.Routing.RouteConstraintBuilder.AddConstraint(string key, object value)

RouteCreationException: An error occurred while creating the route with name 'CustomLogin' and template 'Login/'.
Microsoft.AspNetCore.Routing.RouteBase..ctor(string template, string name, IInlineConstraintResolver constraintResolver, RouteValueDictionary defaults, IDictionary<string, object> constraints, RouteValueDictionary dataTokens)

RouteCreationException: The constraint entry 'Length' - '1' on the route 'Login/' must have a string value or be of a type which implements 'Microsoft.AspNetCore.Routing.IRouteConstraint'.
Microsoft.AspNetCore.Routing.RouteConstraintBuilder.AddConstraint(string key, object value)
Microsoft.AspNetCore.Routing.RouteBase.GetConstraints(IInlineConstraintResolver inlineConstraintResolver, RouteTemplate parsedTemplate, IDictionary<string, object> constraints)
Microsoft.AspNetCore.Routing.RouteBase..ctor(string template, string name, IInlineConstraintResolver constraintResolver, RouteValueDictionary defaults, IDictionary<string, object> constraints, RouteValueDictionary dataTokens)
4 years ago
Hello,

How could you solved this issue?
4 years ago
tareq07 wrote:
Hello,

How could you solved this issue?

Specify cshtml file path in controller action like below.

return View("/Plugins/YourPluginBuiltFolder/.../Filename.cshtml", model);
4 years ago
mhsjaber wrote:
Hello,

How could you solved this issue?
Specify cshtml file path in controller action like below.

return View("/Plugins/YourPluginBuiltFolder/.../Filename.cshtml", model);



Thanks for your quick reply.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.