伙计们,在一定时间内过期的链接的正确状态代码是什么?
我想在过期后发送 404,但也许有更好的 http 状态要发送。
链接示例:
mysite/dir/062011/file.exe
(<-仅在2011年6月工作)
谢谢
410 "消失"怎么样?
请参阅:http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
410 Gone
The requested resource is no longer available at the server and no forwarding
address is known. This condition is expected to be considered permanent.
我在尝试在 C# Web API 中验证过期的验证码时选择了 410 Gone 。我使用 REST API 教程作为参考 https://www.restapitutorial.com/httpstatuscodes.html
/// <summary>
/// Verify email address
/// </summary>
/// <param name="verificationCode">Verification Code for ownership of an email address</param>
/// <returns>Verify Email Update Api Response</returns>
[HttpPut]
[Route("{verificationCode}/verify-email-update")]
[ResponseType(typeof(VerifyEmailChangeApiResponse))]
public async Task<IHttpActionResult> VerifyEmailUpdate(Guid verificationCode)
{
var response = await this.emailVerificationService
.VerifyEmailUpdate(verificationCode)
.ConfigureAwait(false);
switch (response.Result)
{
case VerifyEmailUpdateApiResultType.Ok:
return this.Ok(response);
case VerifyEmailUpdateApiResultType.EmailAddressAlreadyVerified:
return this.Content(HttpStatusCode.Conflict, response);
case VerifyEmailUpdateApiResultType.Expired:
return this.Content(HttpStatusCode.Gone, response);
case VerifyEmailUpdateApiResultType.UnknownProblem:
return this.Content(HttpStatusCode.BadRequest, response);
}
return this.Ok(response);
}