Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

32 lines
1.1 KiB
C#

// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Diagnostics.CodeAnalysis;
namespace System.Web.WebPages
{
public static class HttpContextExtensions
{
[SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#", Justification = "Response.Redirect() takes its URI as a string parameter.")]
public static void RedirectLocal(this HttpContextBase context, string url)
{
if (context.Request.IsUrlLocalToHost(url))
{
context.Response.Redirect(url);
}
else
{
context.Response.Redirect("~/");
}
}
public static void RegisterForDispose(this HttpContextBase context, IDisposable resource)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
RequestResourceTracker.RegisterForDispose(context, resource);
}
}
}