2025-09-25 14:37:10 +08:00
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
2025-10-09 16:26:44 +08:00
|
|
|
|
namespace LM.Core.Extensions
|
2025-09-25 14:37:10 +08:00
|
|
|
|
{
|
|
|
|
|
|
public static class StaticHttpContextExtensions
|
|
|
|
|
|
{
|
|
|
|
|
|
//public static void AddHttpContextAccessor(this IServiceCollection services)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
public static IApplicationBuilder UseStaticHttpContext(this IApplicationBuilder app)
|
|
|
|
|
|
{
|
|
|
|
|
|
var httpContextAccessor = app.ApplicationServices.GetRequiredService<IHttpContextAccessor>();
|
|
|
|
|
|
Utilities.HttpContext.Configure(httpContextAccessor);
|
|
|
|
|
|
return app;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|