[英]WebApi: Accept GET file in path
I'm working at creating a small authentification API for an already existing project. 我正在为现有项目创建小型身份验证API。 The idea is that all calls pass through this API that checks for an access token.
想法是所有调用都通过此API来检查访问令牌。 It works for most of the cases except for when in the path there is any file extension
它适用于大多数情况,但路径中没有文件扩展名时
This works: localhost:26860/TranslationService/widgest/QuotationWidget 这有效:localhost:26860 / TranslationService / widgest / QuotationWidget
This doesn't: localhost:26860/TranslationService/widgest/QuotationWidget.js 这不是:localhost:26860 / TranslationService / widgest / QuotationWidget.js
This is my route: 这是我的路线:
config.Routes.MapHttpRoute(
name: "Default",
routeTemplate: "{*uri}",
defaults: new { controller = "Gateway", uri = RouteParameter.Optional });
Controller: 控制器:
[RoutePrefix("")]
public class GatewayController : ApiController
{
public async Task<HttpResponseMessage> Get(string uri)
{
....
}
What am I doing wrong? 我究竟做错了什么?
if you get 404 error message you should add handler
configuration to handlers section in system.webservice
section: 如果收到404错误消息,则应将
handler
配置添加到system.webservice
部分的handlers部分:
<add
name="jsFileExtension"
path="api/nav/*/*.js"
verb="GET"
type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0"
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.