You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
805 B
29 lines
805 B
using System;
|
|
|
|
namespace Apewer.Web
|
|
{
|
|
|
|
/// <summary>请求资源的 URL 已永久更改。在响应中给出了新的 URL。</summary>
|
|
public sealed class RedirectResult : HeadResult
|
|
{
|
|
|
|
/// <summary>新的 URL。</summary>
|
|
public string Location { get; private set; }
|
|
|
|
/// <summary>重定向结果。</summary>
|
|
/// <exception cref="ArgumentNullException" />
|
|
public RedirectResult(string location) : base(302)
|
|
{
|
|
if (location.IsEmpty()) throw new ArgumentNullException(nameof(location));
|
|
Headers.Add("Location", location);
|
|
}
|
|
|
|
/// <summary>执行。</summary>
|
|
public override void ExecuteResult(ApiContext context)
|
|
{
|
|
context.Provider.SetRedirect(Location);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|