WebFX 156 - Introducing RedirectPermanent.

Merging RedirectPermanent to Redirect.
This commit is contained in:
sornaks 2014-04-01 10:46:23 -07:00
parent ee37c75544
commit 9f3433acec
2 changed files with 16 additions and 3 deletions

View File

@ -23,7 +23,12 @@ namespace Microsoft.AspNet.Abstractions
public abstract void OnSendingHeaders(Action<object> callback, object state); public abstract void OnSendingHeaders(Action<object> callback, object state);
public abstract void Redirect(string location); public virtual void Redirect(string location)
{
Redirect(location, permanent: false);
}
public abstract void Redirect(string location, bool permanent);
public abstract Task WriteAsync(string data); public abstract Task WriteAsync(string data);

View File

@ -107,9 +107,17 @@ namespace Microsoft.AspNet.PipelineCore
HttpResponseInformation.OnSendingHeaders(callback, state); HttpResponseInformation.OnSendingHeaders(callback, state);
} }
public override void Redirect(string location) public override void Redirect(string location, bool permanent)
{ {
HttpResponseInformation.StatusCode = 302; if (permanent)
{
HttpResponseInformation.StatusCode = 301;
}
else
{
HttpResponseInformation.StatusCode = 302;
}
Headers.Set(Constants.Headers.Location, location); Headers.Set(Constants.Headers.Location, location);
} }