1

I am using the following in my code:

 @Ajax.ActionLink(
                                    item.Name,
                                    "NavMenuMdLocationChanged", //ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(),
                                    ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(),
                                    new RouteValueDictionary(new { SelectedLocationId = item.Id }),
                                    new AjaxOptions
                                    {
                                        HttpMethod = "Post",
                                        UpdateTargetId = "nav-menu-md-content",
                                        InsertionMode = InsertionMode.Replace
                                    })

It works fine with no problems. However, I have a couple of things which are a bit of concern to me.

  1. While the operation does the POST operation, the data gets sent using URL (in the form of query string instead of POST message body). Is it supposed to behave that way? If it is so, how is this going to be different than GET operation?

  2. A gentle man (ASP.NET MVC ActionLink and post method) says that 10 it's bad practise to POST forms with javascript/jquery. If he is correct, how do I POST a form using AJAX (together with ASP.NET MVC) and refresh/update only a part of web page (instead of whole page using location.reload())

BTW, I am using ASP.NET MVC 5 for application development.

Community
  • 1
  • 1
user203687
  • 6,875
  • 12
  • 53
  • 85
  • 1
    You might have to rely on a Ajax.BeginForm, with hidden fields for post data, and an hyperlink which would submit the form. See http://stackoverflow.com/q/13459954/1236044 – jbl Dec 04 '13 at 16:12

0 Answers0