Sanju Rao
Sanju Rao

Reputation: 331

Redirect to action is not working

Hi I have a table with anchor tag in a column. when user clicks on the link, My action method in controller redirect to another method after doing some update logic. Redirect to another action method then after, is not working in my case?

my View :

<fieldset>
    <legend>Emended</legend>
    <table border="1">
        <tr>


            <th>
                @Html.DisplayNameFor(model => model.CustomerEmneedOrderedProduct.FirstOrDefault().Prd_Qnty)
            </th>

        </tr>

        @foreach (var item in Model.CustomerEmneedOrderedProduct)
        {
            <tr>

                <td>
                    @Html.DisplayFor(modelItem => item.Prd_Qnty)
                    <br />
                    @Html.ActionLink("Remove", "updateOrderedProdStatuCd", new { orderProductId = item.OrderProductId, OrderedProdStatuCd = 2 })
                </td>


            </tr>
        }

    </table>
</fieldset>

My Controller :

    public class SellerOrderDetailsController : Controller
    {

          public ActionResult OrderDetails([Bind(Prefix = "id")] int? orderId)
          {

          }

         public ActionResult updateOrderedProdStatuCd(int orderProductId, int OrderedProdStatuCd)
         {
                    try
                    {
                        // Updating few stuffs
                    }
                    catch (Exception ex)
                    {

                        throw new Exception(ex.Message);
                    }
                    return RedirectToAction("OrderDetails"); //this is not working 
                }
           }
   }

Upvotes: 2

Views: 1158

Answers (1)

Andrzej Gis
Andrzej Gis

Reputation: 14306

I guess it's because you're not passing orderId to OrderDetails action. The action doesn't match method's signature.

Try something like

return RedirectToAction("OrderDetails ", new { orderId = 123 });

Upvotes: 2

Related Questions