私はすでにこのトピックに関する多くの質問を調査しました。MVC3に関しては、私は前かがみではありませんが、私の人生では、MVC 4ルーティングのWeb Apiが失敗する理由を理解できません。
Fiddler2 はサーバー応答 404 (見つかりません) を示します
IN App_Start/WebApiConfig.cs
config.Routes.MapHttpRoute(
name: "DefaultApiGet",
routeTemplate: "api/{domain}/{controller}",
defaults: new { action = "Get" },
constraints: new { httpMethod = new HttpMethodConstraint(HttpMethod.Get) }
);
config.Routes.MapHttpRoute(
name: "ApiPostWithAction",
routeTemplate: "api/{domain}/{controller}/{action}",
defaults: new { action = "Post" },
constraints: new { httpMethod = new HttpMethodConstraint(HttpMethod.Post) }
);
config.Routes.MapHttpRoute(
name: "DefaultApiPost",
routeTemplate: "api/{domain}/{controller}",
defaults: new { action = "Post" },
constraints: new { httpMethod = new HttpMethodConstraint(HttpMethod.Post) }
);
config.Routes.MapHttpRoute(
name: "ControllerAndId",
routeTemplate: "api/{domain}/{controller}/{id}",
defaults: null,
constraints: new { id = new GuidConstraint() } // Only Guids
);
IN Controllers/Api/[モデル名]Controller
[ActionName("CustomerLogin")]
[HttpPost]
//public HttpResponseMessage CustomerLogin(string username, string password)
public HttpResponseMessage PostCustomerLogin(string username, string password)
{
クライアントからの呼び出しパス
var url = "api/[client_specific_name]/Customer/CustomerLogin";
var userData = new {username:[someusername], password:[somepassword]};
var defaultSettings = {
type: 'POST',
data: userData
};
// SENT TO SERVER VIA AJAX ALONG WITH THE DATA ABOVE
欠けているものが見つかりません。
助言がありますか?