я "м пытается создать обратный прокси-сервер с ASP.Net Web Api 2, используя этот пример: http://kasperholdum.dk/2016/03/reverse-proxy-in-asp-net-web-api/Поймайте весь маршрут не ловить статические файлы
Две вещи, которые являются наиболее важными здесь:
- Добавить DelegatingHandler: config.MessageHandlers.Add (новый ProxyHandler());
- Добавить кетчупа все маршрут: config.Routes.MapHttpRoute ("Эйб", "{*} путь");
Оно работает отлично подходит для основного URL (http://localhost:51101/), когда я нахожусь отладки, но ссылки на статический файл не перенаправляются:
http://localhost:51101/logos/doodles/2016/sigmund-freuds-160th-birthday-4918124856999936-hp.jpg
Если я использую этот адрес, я получаю эту ошибку:
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Most likely causes:
The directory or file specified does not exist on the Web server.
The URL contains a typographical error.
A custom filter or module, such as URLScan, restricts access to the file.
Things you can try:
Create the content on the Web server.
Review the browser URL.
Check the failed request tracing log and see which module is calling SetStatus. For more information, click here.
Detailed Error Information:
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://localhost:57221/logos/doodles/2016/sigmund-freuds-160th-birthday-4918124856999936-hp.jpg
Physical Path c:\users\...\documents\visual studio 2015\Projects\AspNetReversePRoxy2\AspNetReversePRoxy2\logos\doodles\2016\sigmund-freuds-160th-birthday-4918124856999936-hp.jpg
Logon Method Anonymous
Logon User Anonymous
Request Tracing Directory C:\Users\...\Documents\IISExpress\TraceLogFiles\ASPNETREVERSEPROXY2
More Information:
This error means that the file or directory does not exist on the server. Create the file or directory and try the request again.
View more information »
Вопрос
Я допустил ошибку в маршрутизации URL-адреса? Есть ли способ поймать статические файлы? Таким образом, обработчик может перехватить вызов?
По умолчанию IIS не отправляет запросы на статический контент в ASP.NET для обработки, поэтому ваш API не увидит эти запросы. Просмотрите эту статью, это может помочь: http://www.iis.net/learn/application-frameworks/building-and-running-aspnet-applications/wildcard-script-mapping-and-iis-integrated-pipeline – CodingGorilla