0

Есть URL: http://localhost/main/cat/sub/file.jsp

Как сделать роутинг, чтобы при обращении по данному адресу методом POST роутило на метод Post() в указанном в настройках контроллере?

Мои попытки:

WebApiConfig.cs

config.Routes.MapHttpRoute(
    "Main",
    "main/cat/sub/{*src}",
    new { controller = "Main", id = RouteParameter.Optional },
    new { src = @"(.*?)\.(jsp)" }
);

MainController.cs

public class MainController : ApiController
{
    [HttpPost]
    public HttpResponseMessage Post([FromUri]RequestModel values)
    {
        ...
    }
}

В данном случае получаю 404

1 ответ 1

1

Разобрался.
В Web.config необходимо добавить handler c указанием расширения файла:

<system.webServer>
    <handlers>
        <add name="JspFileHandler" path="*.jsp" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
</system.webServer>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.