using System; namespace Apewer.Web { /// 请求资源的 URL 已永久更改。在响应中给出了新的 URL。 public sealed class RedirectResult : HeadResult { /// 新的 URL。 public string Location { get; private set; } /// 重定向结果。 /// public RedirectResult(string location) : base(302) { if (location.IsEmpty()) throw new ArgumentNullException(nameof(location)); Headers.Add("Location", location); } /// 执行。 public override void ExecuteResult(ApiContext context) { context.Provider.SetRedirect(Location); } } }