I have a strange case, and I wanted your enlightenment. I have two controllers. One Person controller for common character usage methods and one candidate controller for more specific candidate actions. I use one partial view, which is located in the Person folder, to use it as a general one if I want to use it in the future for other Person types. So far, this partial view has been using Ajax.BeginForm aimed at the Candidate Controller. The syntax I use is
@using (Ajax.BeginForm("SaveCandidateLanguage", "Candidate",
new AjaxOptions
{
HttpMethod = "Post",
OnBegin = "onBeginFormValidation",
OnSuccess = "onSaveCandidateLanguageSuccess"
}))
{
}
This type of Ajax.BeginForm works correctly, despite the fact that it targets actions in another controller. Now, to validate my form, I had to add a few more arguments to my Ajax.BeginForm. My new syntax is as follows:
@using (Ajax.BeginForm("SaveCandidateLanguage", "Candidate",
new AjaxOptions
{
HttpMethod = "Post",
OnBegin = "onBeginFormValidation",
OnSuccess = "onSaveCandidateLanguageSuccess"
},
new
{
id = "addEditCandidateLanguageForm",
novalidate = "novalidate"
}))
{
}
For some reason, this method cannot find the Action method. If I put my action in the Person Controller, it will work correctly again. However, I was wondering why this is so. I did digging, but I could not get an answer about this.
From firebug, I see that the URL that the browser is trying to publish is somehow
http: // {ProjectName} / Person / SaveCandidateLanguage? Length = 9
instead
HTTP: // {Project_name} / candidate / SaveCandidateLanguage Length = 9
, , 404 . , ? Length = 9, URL- .