小编PPa*_*ann的帖子

更改 ASP.NET Core MVC 中的默认 cookie 名称

我想在 asp.mvc core 3.X 中更改 .AspNetCore.Antiforgery.xxx 的默认 Cookie 名称,但是我似乎没有找到任何关于它的文档。甚至有可能吗?

我发现唯一可以改变的是:

services.Configure<CookiePolicyOptions>(options =>
{
  options.CheckConsentNeeded = context => true;
  options.MinimumSameSitePolicy = Microsoft.AspNetCore.Http.SameSiteMode.Strict;
  options.ConsentCookie.Name = "GDRP";
});
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core

7
推荐指数
2
解决办法
2100
查看次数

找不到 IEndpointRouteBuilder 接口

我有

NuGet Microsoft.AspNetCore.Http.Abstractions
NuGet Microsoft.AspNetCore.Routing
Run Code Online (Sandbox Code Playgroud)

并使用命名空间

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
Run Code Online (Sandbox Code Playgroud)

我想构建这样的东西,但它似乎不知道 IEndpointConventionBuilder 也不知道 IEndpointRouteBuilder 并且拒绝编译。

public static class EndpointRouteBuilderExtensions
{
    public static IEndpointConventionBuilder MapServiceEndpoints(this IEndpointRouteBuilder endpoints)
    {

       //some code
    }
}
Run Code Online (Sandbox Code Playgroud)

我错过了什么......?

asp.net routes core

4
推荐指数
2
解决办法
1074
查看次数

当我在 asp.net core 3.1 中工作时收到此错误值不能为空。(参数'connectionString')

System.ArgumentNullException: '值不能为空。(参数'connectionString')

我收到此错误我认为该问题来自 appsetting.json 但我找不到它

 "AllowedHosts": "*",
    "ConnectionString": {
        "EmployeeDbConnection" : "server=(localdb)\\MSSQLLocalDB;database=EmployeeDB;Trusted_Connection=true;"
    }
Run Code Online (Sandbox Code Playgroud)

错误来自 _config.GetConnectionString("EmployeeDbConnection)

public Startup(IConfiguration config)
        {
            _config = config;
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
           
            services.AddDbContextPool<AppDbContext>(options => options.UseSqlServer(_config.GetConnectionString("EmployeeDbConnection")));
            
            services.AddScoped<IEmployeeRepository, SqlServerRepository>();
            services.AddMvc(options => options.EnableEndpointRouting = false).AddXmlSerializerFormatters();
        }
Run Code Online (Sandbox Code Playgroud)

c# model-view-controller asp.net-core

3
推荐指数
1
解决办法
128
查看次数

标签 统计

asp.net-core ×2

c# ×2

asp.net ×1

core ×1

model-view-controller ×1

routes ×1