Hello all,
I have written a new plugin that overrides the Customer-Checkout controllers in nop.web, as well as the customer-checkout controllers in the official plugin (nop.plugin.misc.webapi.frontend). All of the controllers, both in the web and API, have the same methods with the same names and types. I have only overridden the methods that I need to override their input objects, such as the addressadd and addressedit methods in both the web and API controllers.
All of the controllers have area information, and in the routeprovider, I have added every method. The web routings are working fine. I have rerouted the nop.web methods like this:
Class:
[Area("public")]
[ApiExplorerSettings(IgnoreApi = true)]
public partial class CustomerController : Nop.Web.Controllers.CustomerController
Methods:
[HttpPost]
[Route("/Customer/AddressAdd")]
public async Task<IActionResult> AddressAdd(WebCustomerAddressEditModel model, IFormCollection form)
The API controller methods are examples like this:
[Area("frontendapi")]
[ApiExplorerSettings(IgnoreApi = true)]
[Route("/api-frontend/[controller]/[action]")]
public partial class CustomerController : WebApi.Frontend.Controllers.CustomerController
Method example:
[HttpPost]
[ProducesResponseType(typeof(string), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(FrontendCustomerAddressEditModelDto), StatusCodes.Status200OK)]
[Route("/api-frontend/Customer/AddressAdd")]
public async Task<IActionResult> AddressAdd([FromBody] BaseModelDtoRequest<FrontendCustomerAddressEditModelDto> request)
However, in the API controllers, the methods that do not have an "override" expression (like the addressadd post method) do not work as expected and throw an error like this:
Error: response status is 500 Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches: Nop.Plugin.Misc.FoDynamicsCrm.Controllers.Api.FrontEnd.CustomerController.AddressAdd (Nop.Plugin.Misc.FoDynamicsCrm) Nop.Plugin.Misc.FoDynamicsCrm.Controllers.Api.FrontEnd.CustomerController.AddressAdd (Nop.Plugin.Misc.FoDynamicsCrm) Nop.Plugin.Misc.WebApi.Frontend.Controllers.CustomerController.AddressAdd (Nop.Plugin.Misc.WebApi.Frontend)
Do you have any suggestions on how to fix this problem?