简体   繁体   中英

Geting no page found error in Ajax request asp.net mvc

Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Contact/PopBid

Controller

[HttpPost]
    public ActionResult PopBid(int jobid)
    {

        var getjob = _context.jobService.GetById(jobid);
        return View();
    }

JavaScript

      function Singin(jobid) {
            $.fancybox({

                'transitionIn': 'elastic',
                'transitionOut': 'elastic',
                'easingIn': 'easeOutBack',
                'easingOut': 'easeInBack',
                'width': 850,
                'height': 394,
                href: "/Contact/PopBid",
                data: "jobid=" + jobid,
                'type': 'iframe'
            });
        }s

 <img alt="" onclick="javascript:Singin(@job.ID);" src="/Content/WalkFish/Images/bidimg1.png" style="width: 180px; height: 140px;">

onclick event

pop open well but get error in the pop that

Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Contact/PopBid

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

Looks like you are GETing /Contact/PopBid not POSTing to it. Because of the [HttpPost] attribute above you method the GET action is not available.

Change the attribute to [HttpGet]

[HttpGet]
public ActionResult PopBid(int jobid)
{

    var getjob = _context.jobService.GetById(jobid);
    return View();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM