search

Home  >  Q&A  >  body text

angular.js - ANGULARJS HTTP.GET transfers value, but the parameter value cannot be received in the background

HTML:

<button type="submit" ng-click="get3(model.Name)">查询</button>


js:
$scope.get3 = function (name) {
        $http.get("/Movies/Search/" + name).success(function (data) {
            $scope.model = data;
        })
    }(这边name可以收到前台传过来的值)

MVC CONTROLLER:
public ActionResult Search(string Name)
        {


            var movie9 = db.Movies.Where(p => p.Name == Name);
            Movie movied = (Movie)movie9;
            return Json(new
            {
                Name = movied.Name,
                Genra = movied.Genra

            }, JsonRequestBehavior.AllowGet);
        }

(The parameter Name here is always NULL, that is to say, the value cannot be passed from the JS side)

我想大声告诉你我想大声告诉你2775 days ago745

reply all(1)I'll reply

  • 滿天的星座

    滿天的星座2017-05-15 16:51:26

    Enter ../Movies/Search/xxxx directly into the browser and see if there is a value on the server side. If there is no value on the server side, it means it is not a problem with Angular $http, but a problem with your ASP.NET MVC routing settings. .

    reply
    0
  • Cancelreply