gpt4 book ai didi

aspnetboilerplate - Asp.net Core 2.2 app.UseHttpsRedirection() 未定义

转载 作者:行者123 更新时间:2023-12-02 03:10:18 24 4
gpt4 key购买 nike

当我尝试使用 app.UseHttpsRedirection() 方法时,它给我一个构建错误:

'IApplicationBuilder' does not contain a definition for 'UseHttpsRedirection' and no accessible extension method 'UseHttpsRedirection' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?

我尝试安装 Microsoft.AspNetCore.HttpsPolicy nuget 包。

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseAbp(); // Initializes ABP framework.

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
}

app.UseStaticFiles();
app.UseHttpsRedirection();
app.UseAuthentication();

app.UseCookiePolicy();
app.UseHttpMethodOverride

app.UseJwtTokenMiddleware();

app.UseSignalR(routes =>
{
routes.MapHub<AbpCommonHub>("/signalr");
});

app.UseMvc(routes =>
{
routes.MapRoute(
name: "defaultWithArea",
template: "{area}/{controller=Home}/{action=Index}/{id?}");

routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}

最佳答案

UseHttpsRedirection 是一个隐藏在Microsoft.AspNetCore.HttpsPolicy DLL。您必须添加它(通过 NuGet 或手动)

请参阅accepted answer here对于您可能需要的更多 DLL

关于aspnetboilerplate - Asp.net Core 2.2 app.UseHttpsRedirection() 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57794929/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com