1 回答
TA贡献1735条经验 获得超5个赞
产品团队建议使用以下类来替换 AcceptedAtRouteResult 返回类型,直到可以更正错误为止:
class AcceptedObjectResult : ObjectResult
{
private readonly string _location;
public AcceptedObjectResult(string location, object value) : base(value)
{
_location = location;
}
public override Task ExecuteResultAsync(ActionContext context)
{
context.HttpContext.Response.StatusCode = 202;
var uri = new UriBuilder(context.HttpContext.Request.Scheme, context.HttpContext.Request.Host.Host)
{
Path = $@"api/{_location}",
};
if (context.HttpContext.Request.Host.Port.HasValue)
{
uri.Port = context.HttpContext.Request.Host.Port.Value;
}
context.HttpContext.Response.Headers.Add(@"Location", uri.ToString());
return base.ExecuteResultAsync(context);
}
}
可以在 Github 上跟踪错误票:https ://github.com/Azure/azure-functions-host/issues/4267
- 1 回答
- 0 关注
- 87 浏览
添加回答
举报