I have tried several different ways to try and call an MVC 4 controller method almost all of them have been 404s.
ive also looked at many different posts and websites trying to get it to work but i have had no success my controller looks like this
public class AjaxController : Controller
{
public ActionResult AjaxContactForm()
{
Data.DataUtilities.ForwardCustomerEmail();
var pause = "";
var result = "";
return Json(result);
}
}
the path of the controller is Portfolio(root)\Controllers\AjaxController.cs
almost every url that i have tried results in a 404
this is what i have currently
var params = {
conName: contactName,
conEmail: contactEmail,
conMessage: contactMessage
};
$.ajax({
url: '<%:Url.Action("AjaxContactForm","AjaxController") %>',
type: "post",
success: function () {
}
});
ive tried
'<%:Url.Action("AjaxContactForm","Controller/AjaxController") %>'
'<%:Url.Action("AjaxContactForm","/Controller/AjaxController") %>'
'<%:Url.Action("AjaxContactForm","/Controllers/HomeController.cs") %>'
'/AjaxController/AjaxContactForm'
'Controller/AjaxController/AjaxContactForm'
'/Controller/AjaxController/AjaxContactForm'
ive done all these as well using a $.post but i can never hit the method.
what am i doing wrong
It should be
AjaxController
should be referenced as"Ajax"
.HomeController
should be referenced as"Home"
.etc.