The current request for action 'Cart' on controller type 'ShoppingCartController' is ambiguous between the following action methods

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 年 前
Hi,

I get the next error on some custom code:
The current request for action 'Cart' on controller type 'ShoppingCartController'
is ambiguous between the following action methods:

The idea is that users enter next to the discount coupon code an additional number 'qediscountreference'. For some customers the apply discount works, and other throw a server error.

How can I fix this?

J.




System.Web.Mvc.ActionResult StartCheckout(System.Web.Mvc.FormCollection) on type Nop.Web.Controllers.ShoppingCartController
System.Web.Mvc.ActionResult ApplyDiscountCoupon(System.String, System.String, System.Web.Mvc.FormCollection) on type Nop.Web.Controllers.ShoppingCartController


Code snippet in ShoppingCartController:



  [ValidateInput(false)]
        [HttpPost, ActionName("Cart")]
        [FormValueRequired("checkout")]
        public ActionResult StartCheckout(FormCollection form)
        {

....
        [ValidateInput(false)]
        [HttpPost, ActionName("Cart")]
        //[FormValueRequired("applydiscountcouponcode")]        
        //public ActionResult ApplyDiscountCoupon(string discountcouponcode, FormCollection form)
        [FormValueRequired("applydiscountcouponcode", "qediscountreference")]        
        public ActionResult ApplyDiscountCoupon(string discountcouponcode, string qediscountreference, FormCollection form)
        {


Code snippeter in _DiscountBox.cshtml



        <div class="coupon-code">
            <input name="qediscountreference" type="text" class="discount-coupon-code" />
            <input type="submit" name="applydiscountcouponcode" value="@T("ShoppingCart.DiscountCouponCode.Button")" class="button-2 apply-discount-coupon-code-button" />
        </div>

9 年 前
Hi,
I do not see any errors in my development environment. I tried to fix this way so that the call is similar in number of parameters as it was originally. Testing now if this works.
J.


        [ValidateInput(false)]
        [HttpPost, ActionName("Cart")]
        //[FormValueRequired("applydiscountcouponcode")]        
        //public ActionResult ApplyDiscountCoupon(string discountcouponcode, FormCollection form)
        [FormValueRequired("applydiscountcouponcode", "qediscountreference")]        
        //public ActionResult ApplyDiscountCoupon(string discountcouponcode, string qediscountreference, FormCollection form)
        public ActionResult ApplyDiscountCoupon(string discountcouponcode, FormCollection form)
        {
            var cart = _workContext.CurrentCustomer.ShoppingCartItems
                .Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart)
                .Where(sci => sci.StoreId == _storeContext.CurrentStore.Id)
                .ToList();
            
            //parse and save checkout attributes
            ParseAndSaveCheckoutAttributes(cart, form);
            
            var model = new ShoppingCartModel();
            if (!String.IsNullOrWhiteSpace(discountcouponcode))
            {
                var discount = _discountService.GetDiscountByCouponCode(discountcouponcode);

                string qediscountreference = form["qediscountreference"];
9 年 前
Hi,

This seems a IE 8 problem. It throws an internal server error.

I see with F12 that next values are posted:


-----------------------------7de2391330346
Content-Disposition: form-data; name="itemquantity12776"

1
-----------------------------7de2391330346
Content-Disposition: form-data; name="discountcouponcode"

tests
-----------------------------7de2391330346
Content-Disposition: form-data; name="qediscountreference"

asdf
-----------------------------7de2391330346
Content-Disposition: form-data; name="applydiscountcouponcode"

Coupon toepassen
-----------------------------7de2391330346--


I can however not install a IE 8 browser on an Windows 8.1 64 bit machine ...so cannot see what that browser posts. Any help appreciated.

J.
9 年 前
Hi,

I resolved the internal server error by changing. [FormValueRequired("applydiscountcouponcode")] However, still not working in IE8 still not working (according to customer). I am wondering if enctype can cause problem?..although it is supported in IE?

http://msdn.microsoft.com/en-us/library/ie/cc304100(v=vs.85).aspx

J.


@*we add enctype = "multipart/form-data" because "File upload" attribute control type requries it*@
        using (Html.BeginRouteForm("ShoppingCart", FormMethod.Post, new { enctype = "multipart/form-data" }))
        {

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