Я пытаюсь получить мою страницу, чтобы опубликовать ее на моем веб-API-контроллере, а не на моем Area/Controller/Action. Вот то, что я до сих пор, я попытался использовать как Html.BeginForm и Ajax.Begin Форма:Html.BeginForm routing to Web Api
@using (Ajax.BeginForm("", "", null, new AjaxOptions { HttpMethod = "POST", Url = "api/Standing" }, new { id = "frmStandingAdd", name = "frmStandingAdd" }))
@using (Html.BeginForm("", "api/Standing", FormMethod.Post, new { id = "frmStandingAdd", name = "frmStandingAdd" }))
Но я не могу получить либо опубликовать в корневой т.е. http://domain/api/Standing
, а не как пост Района т.е. http://domain/Areaname/api/Standing
, Как мне получить сообщение правильно?
Update: Вот мои маршруты для соответствующей области:
public override string AreaName
{
get
{
return "Areaname";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
string defaultLocale = "en-US";
context.MapRoute(
"Areaname_default",
"{languageCode}/Areaname/{controller}/{action}/{id}",
new { languageCode = defaultLocale, controller = "Main", action = "Index", id = UrlParameter.Optional });
context.MapRoute(
"History",
"{languageCode}/Areaname/{controller}/{action}/{year}",
new { controller = "History", action = "Season", year = UrlParameter.Optional });
}
И мой Web API маршрутов:
config.Routes.MapHttpRoute(
"DefaultApi",
"api/{controller}/{id}",
new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
"DefaultApiWithAction",
"api/{controller}/{action}/{season}",
new { id = RouteParameter.Optional }
);
Пожалуйста, оставьте свои 'routes' – haim770