forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpContextExtensions.cs
More file actions
32 lines (29 loc) · 1.1 KB
/
Copy pathHttpContextExtensions.cs
File metadata and controls
32 lines (29 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. 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);
}
}
}