https://github.com/ttakahari/aspnetcorecurrentrequestcontext
Enable HttpContext.Current on ASP.NET Core applications.
https://github.com/ttakahari/aspnetcorecurrentrequestcontext
asp-net-core aspnet-core aspnetcore csharp
Last synced: 10 months ago
JSON representation
Enable HttpContext.Current on ASP.NET Core applications.
- Host: GitHub
- URL: https://github.com/ttakahari/aspnetcorecurrentrequestcontext
- Owner: ttakahari
- License: mit
- Created: 2017-01-30T15:56:33.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-06-02T04:22:50.000Z (about 8 years ago)
- Last Synced: 2025-07-12T02:12:57.754Z (12 months ago)
- Topics: asp-net-core, aspnet-core, aspnetcore, csharp
- Language: C#
- Size: 15.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AspNetCoreCurrentRequestContext
Enable to use HttpContext.Current on ASP.NET Core applications.
[](https://ci.appveyor.com/project/ttakahari/AspNetCoreCurrentRequestContext)
[](https://www.nuget.org/packages/AspNetCoreCurrentRequestContext/)
## Install
from NuGet - [AspNetCoreCurrentRequestContext](https://www.nuget.org/packages/AspNetCoreCurrentRequestContext/)
```ps1
PM > Install-Package AspNetCoreCurrentRequestContext
```
## How to use
At first, you have to add ```CurrentRequestContextMiddleware``` to ```IApplicationBuilder``` on ```Configure``` method in ```Startup``` class.
You can use the extension-method that is ```UseCurrentRequestContext``` for doing that.
```csharp
public class Startup
{
public void Configure(IApplicationBuilder app)
{
// add CurrentRequestContextMiddleware.
app.UseCurrentRequestContext();
}
}
```
After that, if you call ```AspNetCoreHttpContext.Current``` like ```HttpContext.Current``` on ASP.NET applications, you can use ```HttpContext``` everywhere.
```csharp
// you can get HttpContext in the current request.
var context = AspNetCoreHttpContext.Current;
```
## Lisence
under [MIT Lisence](https://opensource.org/licenses/MIT).