asp.net5

.NET 5.0 Web API won't work with record featuring required properties

不问归期 提交于 2021-02-10 07:12:59
问题 I'm using a C# 9.0 record type as a binding model for a .NET 5.0 Web API project. Some of the properties are required. I'm using the record positional syntax, but am receiving errors. public record Mail( System.Guid? Id, [property: Required] string From, [property: Required] string[] Tos, [property: Required] string Subject, string[]? Ccs, string[]? Bccs, [property: Required] Content[] Contents, Attachment[]? Attachments ); This is then exposed as the binding model for my Index action: public

.NET 5.0 Web API won't work with record featuring required properties

妖精的绣舞 提交于 2021-02-10 07:10:57
问题 I'm using a C# 9.0 record type as a binding model for a .NET 5.0 Web API project. Some of the properties are required. I'm using the record positional syntax, but am receiving errors. public record Mail( System.Guid? Id, [property: Required] string From, [property: Required] string[] Tos, [property: Required] string Subject, string[]? Ccs, string[]? Bccs, [property: Required] Content[] Contents, Attachment[]? Attachments ); This is then exposed as the binding model for my Index action: public

app.UseMiddleware<T>() causing 500

馋奶兔 提交于 2020-01-06 16:16:28
问题 If I call the middleware directly in my startup.cs , e.g.: public void Configure(IApplicationBuilder app) { app.UseMiddleware<StaticFileMiddleware>(); app.UseMiddleware<DefaultFilesMiddleware>(); } Looking at the source on GitHub, this is exactly the code that the extension methods are calling. However, I'm getting a 500 error and a stack trace: :( Oops. 500 Internal Server Error System.InvalidOperationException The 'Invoke' method's first argument must be of type 'HttpContext'. at Microsoft

VS exported template does not work with new project

旧城冷巷雨未停 提交于 2019-12-23 11:40:40
问题 I have exported the following working project as a VS template, which uses ASP.NET 5 RC1 : https://github.com/mohasi/vs.spa.template When I create a new project using it I get almost nothing : What am I doing wrong? 来源: https://stackoverflow.com/questions/36720652/vs-exported-template-does-not-work-with-new-project

VS 2015: Profiling tools disabled in Performance Wizard

a 夏天 提交于 2019-12-22 03:22:37
问题 I want to sample the performance of our application, but the various tools (such as CPU Usage and Application Timeline) are not available when trying to start a new profiling session with the Performance Wizard: I am using Visual Studio 2015 Professional. The application is using ASP.NET 5 RC1 and is running from Kestrel (not IIS). Why could this be happening? 回答1: As a workaround, you can use the "Diagnostic Tools" panel when debugging, it has a CPU profiler built in. 来源: https:/

How do I integration test a ASP 5/Core Web API with [Authorize] Attributes

点点圈 提交于 2019-12-12 11:28:59
问题 I currently have an ASP 5/ASP Core Web API that I need to integration test with the OWIN Test Server. The problem is that I use IdentityServer as the authorization server in production and I do not want to include the authorization as part of my integration testing. This is the Startup.cs of the API: public Startup(IHostingEnvironment env) { // Set up configuration sources. IConfigurationBuilder builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.

EF 7 Migration to Existing Database

旧街凉风 提交于 2019-12-09 12:22:55
问题 I am working on a web project using ASP.Net 5 and EF7. I have imported all the tables from existing database onto my models in my project. However, I am having problems in regards with migrations. I have created the initial migration, made some changes on particular entity, create another migration following the changes I have made and now want to apply the changes on the database. After running this command below: dnx ef database update [Migration] the dnx is trying to apply the 'initial'

VS 2015: Profiling tools disabled in Performance Wizard

百般思念 提交于 2019-12-05 00:10:38
I want to sample the performance of our application, but the various tools (such as CPU Usage and Application Timeline) are not available when trying to start a new profiling session with the Performance Wizard: I am using Visual Studio 2015 Professional. The application is using ASP.NET 5 RC1 and is running from Kestrel (not IIS). Why could this be happening? As a workaround, you can use the "Diagnostic Tools" panel when debugging, it has a CPU profiler built in. 来源: https://stackoverflow.com/questions/36908346/vs-2015-profiling-tools-disabled-in-performance-wizard

EF 7 Migration to Existing Database

别说谁变了你拦得住时间么 提交于 2019-12-03 16:11:29
I am working on a web project using ASP.Net 5 and EF7. I have imported all the tables from existing database onto my models in my project. However, I am having problems in regards with migrations. I have created the initial migration, made some changes on particular entity, create another migration following the changes I have made and now want to apply the changes on the database. After running this command below: dnx ef database update [Migration] the dnx is trying to apply the 'initial' migration with all the entities which are already in database and this causes an error as below: { There

ASP.Net MVC Angular 2 Final

女生的网名这么多〃 提交于 2019-12-03 07:28:20
问题 Has anyone tried Angular 2 RC Final with ASP.Net MVC? I am having trouble with configuring Angular 2 RC 6 with ASP.Net MVC, till beta 17 everything was working fine. The package.json with below configuration doesn't seems to be working: "dependencies": { "@angular/common": "2.0.0-rc.6", "@angular/compiler": "2.0.0-rc.6", "@angular/core": "2.0.0-rc.6", "@angular/forms": "0.3.0", "@angular/http": "2.0.0-rc.6", "@angular/platform-browser": "2.0.0-rc.6", "@angular/platform-browser-dynamic": "2.0