weixin_33725807 2018-06-16 20:12 采纳率: 0%
浏览 31

在Ajax发布时出现404错误

I am new at web dev and am trying to get a post method to successfully run.

Here is my ajax call:

    $.ajax({
        type: "POST",
        url: '/Controllers/AddPropertyData',
        contentType: "application/json; charset=utf-8",
        data: null, //Maps the controller params
        dataType: "json",
        success: function() { alert('Success'); }
    });

I have also tried this call with the url as: "/AddPropertyData". Here is the post method I am trying to call which currently does nothing but return the view (removed all functionality for testing).

    [HttpPost]
    public ActionResult AddPropertyData(){

        return View();
    }

Everything I've tried has resulted in a 404 error. I am using the new Visual Studio for Mac and I've noticed that some of the config files have weird default values. I have changed my Startup.cs file as such:

        app.MapHttpRoute(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });

It used to be app.UseMVC or something along those lines.

Any help would be greatly appreciated! Thanks.

  • 写回答

1条回答 默认 最新

  • weixin_33725807 2018-06-16 20:25
    关注

    You are getting an error 404 which according to HTTP means Not Found. You probably on the wrong route which doesn't map to any resource.

    评论

报告相同问题?

悬赏问题

  • ¥15 对于知识的学以致用的解释
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败