草庐IT

core_cmInstr

全部标签

c# - 无法解析 ASP.NET Core 2.0 中的 DbContext

首先,我正在尝试使用样本数据为我的数据库做种。我已经读到这是这样做的方法(在Startup.Configure中)(请参阅ASP.NETCoreRC2SeedDatabase)我正在使用具有默认选项的ASP.NETCore2.0。像往常一样,我在ConfigureServices中注册了我的DbContext。但之后,在Startup.Configure方法中,当我尝试使用GetRequiredService解决它时,它会抛出此消息:System.InvalidOperationException:'Cannotresolvescopedservice'SGDTP.Infrastruc

c# - 无法解析 ASP.NET Core 2.0 中的 DbContext

首先,我正在尝试使用样本数据为我的数据库做种。我已经读到这是这样做的方法(在Startup.Configure中)(请参阅ASP.NETCoreRC2SeedDatabase)我正在使用具有默认选项的ASP.NETCore2.0。像往常一样,我在ConfigureServices中注册了我的DbContext。但之后,在Startup.Configure方法中,当我尝试使用GetRequiredService解决它时,它会抛出此消息:System.InvalidOperationException:'Cannotresolvescopedservice'SGDTP.Infrastruc

c# - JsonSerializerSettings 和 Asp.Net Core

尝试设置JsonOutputFormatter选项:varjsonFormatter=(JsonOutputFormatter)options.OutputFormatters.FirstOrDefault(f=>fisJsonOutputFormatter);if(jsonFormatter!=null){jsonFormatter.SerializerSettings.ContractResolver=newCamelCasePropertyNamesContractResolver();}或mvcBuilder.AddJsonOptions(jsonOptions=>{jsonO

c# - JsonSerializerSettings 和 Asp.Net Core

尝试设置JsonOutputFormatter选项:varjsonFormatter=(JsonOutputFormatter)options.OutputFormatters.FirstOrDefault(f=>fisJsonOutputFormatter);if(jsonFormatter!=null){jsonFormatter.SerializerSettings.ContractResolver=newCamelCasePropertyNamesContractResolver();}或mvcBuilder.AddJsonOptions(jsonOptions=>{jsonO

c# - ef core 在更新数据库期间不使用 ASPNETCORE_ENVIRONMENT

我使用visualstudio通过特定的迁移来更新我的所有环境。使用下面的命令它运行良好。update-database-MigrationinitMigrationProduct-cProductContext-EnvironmentProduction在efcore2.0中,此命令已更改,参数-Environment已删除。它在文档中说。"With2.0,youcanusetheASPNETCORE_ENVIRONMENTenvironmentvariableinstead."https://learn.microsoft.com/en-us/ef/core/miscellaneo

c# - ef core 在更新数据库期间不使用 ASPNETCORE_ENVIRONMENT

我使用visualstudio通过特定的迁移来更新我的所有环境。使用下面的命令它运行良好。update-database-MigrationinitMigrationProduct-cProductContext-EnvironmentProduction在efcore2.0中,此命令已更改,参数-Environment已删除。它在文档中说。"With2.0,youcanusetheASPNETCORE_ENVIRONMENTenvironmentvariableinstead."https://learn.microsoft.com/en-us/ef/core/miscellaneo

c# - IIS 服务器和 ASP.Net Core - 500.19,httpplatformhandler 标签上的错误代码为 0x8007000d

当我尝试使用IIS服务器v7.5启动我的ASP.NetCore应用程序时出现以下错误...我已成功将网站(VisualStudio中的文件系统选项)发布到特定目录。它从approot/web.cmd文件启动正常。但是,当我尝试将其连接到IIS服务器并将其指向wwwroot文件夹时,出现以下错误:HTTPError500.19-InternalServerErrorTherequestedpagecannotbeaccessedbecausetherelatedconfigurationdataforthepageisinvalid.DetailedErrorInformationMod

c# - IIS 服务器和 ASP.Net Core - 500.19,httpplatformhandler 标签上的错误代码为 0x8007000d

当我尝试使用IIS服务器v7.5启动我的ASP.NetCore应用程序时出现以下错误...我已成功将网站(VisualStudio中的文件系统选项)发布到特定目录。它从approot/web.cmd文件启动正常。但是,当我尝试将其连接到IIS服务器并将其指向wwwroot文件夹时,出现以下错误:HTTPError500.19-InternalServerErrorTherequestedpagecannotbeaccessedbecausetherelatedconfigurationdataforthepageisinvalid.DetailedErrorInformationMod

c# - 如何测试asp.net core内置的Ilogger

我想验证一些记录的日志。我使用的是asp.netcore内置的ILogger,并用asp.netcore内置的DI注入(inject)它:privatereadonlyILogger_logger;publicInvoiceApi(ILoggerlogger){_logger=logger;}然后我像这样使用它:_logger.LogError("error));我试着像往常一样模拟它(用最小起订量):MockLogger=newMock>();并将其注入(inject)到服务中进行测试:newInvoiceApi(MockLogger.Object);然后尝试验证:MockLogge

c# - 如何测试asp.net core内置的Ilogger

我想验证一些记录的日志。我使用的是asp.netcore内置的ILogger,并用asp.netcore内置的DI注入(inject)它:privatereadonlyILogger_logger;publicInvoiceApi(ILoggerlogger){_logger=logger;}然后我像这样使用它:_logger.LogError("error));我试着像往常一样模拟它(用最小起订量):MockLogger=newMock>();并将其注入(inject)到服务中进行测试:newInvoiceApi(MockLogger.Object);然后尝试验证:MockLogge