Skip to content

Commit 9570f39

Browse files
committed
Added extension to get domain name from HttpContext
1 parent c31d9cf commit 9570f39

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// MADE Apps licenses this file to you under the MIT license.
2+
// See the LICENSE file in the project root for more information.
3+
4+
namespace MADE.Web.Extensions
5+
{
6+
using Microsoft.AspNetCore.Http;
7+
8+
/// <summary>
9+
/// Defines a collection of extensions for a <see cref="HttpContext" /> object.
10+
/// </summary>
11+
public static class HttpContextExtensions
12+
{
13+
/// <summary>
14+
/// Gets the domain name of the requesting context.
15+
/// </summary>
16+
/// <param name="context">The requesting <see cref="HttpContext"/>.</param>
17+
/// <returns>The domain part of the request's host.</returns>
18+
public static string GetDomain(this HttpContext context)
19+
{
20+
return context.Request.Host.Host;
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)