How to return JSON in a ASP.NET MVC/web controller?

后端 未结 2 1536
梦如初夏
梦如初夏 2020-12-12 03:51

My problem is that I\'ve been following ASP.net MVC/API tutorials I have a working controller in the MVC side of things. For instance this works fine and returns my data in

2条回答
  •  醉话见心
    2020-12-12 04:35

    One thing that seems to be missing is your "AcceptVerbs" annotation.

    [AcceptVerbs(HttpVerbs.Get)]
    public async Task MethodName()
    {
        return json(model, JSonRequestBehavior.AllowGet);
    }
    

提交回复
热议问题