asp.net-core

Debug level information fails to output in VS Code

纵然是瞬间 提交于 2021-02-20 04:01:25
问题 In the ConfigureServices method I'm using: var loggerFactory = new LoggerFactory(); loggerFactory.AddDebug(); However, use of LogDebug() fails to output to the debug console. 回答1: Rather than rely on AddDebug()... specify the minimum log level with AddConsole() and the debug level information outputs to the console as expected: loggerFactory.AddConsole(LogLevel.Debug); This works because the methods AddConsole(), AddDebug() etc. only specify where to log information. The issue is discussed in

Using signalR in asp.net core, how do I change the userID convention to use the users email address instead of default userId?

谁说胖子不能爱 提交于 2021-02-20 04:00:53
问题 Im using <PackageReference Include="Microsoft.AspNetCore.SignalR.Core" Version="1.1.0" /> in an asp.net core web api. I can see by default that if I want to send a specific user a message I can call a method such as _hub.Clients.User("c5MOTEmXsEZjoVf-y_sVQD_g-yBis9fvLMbyNJX3M31").SendAsync("MessageUpdated", "ee"); However, I would like to know, is there any way to change this such that I can instead pass in a different value for the userId? For example, users email address instead? Is this

How can I switch the database provider used by EF Core based on configuration?

孤者浪人 提交于 2021-02-20 00:25:51
问题 EF Core supports a lot of different providers and I can configure them in Startup.cs by specifying the provider. For example, if I want to use SQL Server, I can use: services.AddDbContext<SomeContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("SomeDatabase")); }); But the DB provider (SQL Server) seems to be hard-coded here. What I want to achieve is set the DB provider based on configuration so I can switch the DB provider based on configuration. Is there a way to

How can I switch the database provider used by EF Core based on configuration?

妖精的绣舞 提交于 2021-02-20 00:25:34
问题 EF Core supports a lot of different providers and I can configure them in Startup.cs by specifying the provider. For example, if I want to use SQL Server, I can use: services.AddDbContext<SomeContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("SomeDatabase")); }); But the DB provider (SQL Server) seems to be hard-coded here. What I want to achieve is set the DB provider based on configuration so I can switch the DB provider based on configuration. Is there a way to

How can I switch the database provider used by EF Core based on configuration?

限于喜欢 提交于 2021-02-20 00:24:53
问题 EF Core supports a lot of different providers and I can configure them in Startup.cs by specifying the provider. For example, if I want to use SQL Server, I can use: services.AddDbContext<SomeContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("SomeDatabase")); }); But the DB provider (SQL Server) seems to be hard-coded here. What I want to achieve is set the DB provider based on configuration so I can switch the DB provider based on configuration. Is there a way to

How can I switch the database provider used by EF Core based on configuration?

主宰稳场 提交于 2021-02-20 00:22:45
问题 EF Core supports a lot of different providers and I can configure them in Startup.cs by specifying the provider. For example, if I want to use SQL Server, I can use: services.AddDbContext<SomeContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("SomeDatabase")); }); But the DB provider (SQL Server) seems to be hard-coded here. What I want to achieve is set the DB provider based on configuration so I can switch the DB provider based on configuration. Is there a way to

.NET Core rc2 WebAPI with index.html as default page

霸气de小男生 提交于 2021-02-19 23:58:31
问题 I have set up an empty WebAPI project with .NET Core rc2 and have it wired up with Angular2 rc1 . Angular will handle everything view related and the WebAPI is the backend. When I start the app by default it comes up with localhost:4578/api/values from the default API controller as startpage. However, I want it to show index.html by default which is located in wwwroot and is hosting my Angular2 app. In Startup.cs the Configure method looks like this: public void Configure(IApplicationBuilder

Angular with Azure AD B2C Audience Validation Failed

Deadly 提交于 2021-02-19 08:39:06
问题 I have an Anuglar5 spa frontend and ASP.NET Core API. Both secured by Azure AD B2C service. The angular application redirects correctly to the login page and signing in returns a token. When I try to call the API with the token I get; AuthenticationFailed: IDX10214: Audience validation failed. Audiences: '627684f5-5011-475a-9cbd-55fcdcdf369e'. Did not match: validationParameters.ValidAudience: 'ee8b98a0-ae7a-38b2-9e73-d175df22ef4c' or validationParameters.ValidAudiences: 'null'. "627684f5

How to lower memory usage in FileStreamResult api

China☆狼群 提交于 2021-02-19 08:37:11
问题 Right now I have an api that gets many results (800k) and it should parse and stream them as CSV. The (kind of) working code I have is this var query = context.address.AsNoTracking(); MemoryStream memoryStream = new MemoryStream(); StreamWriter writer = new StreamWriter(memoryStream); foreach (var row in query) { writer.WriteLine(row.Name+","+row.Surname+","+row.BirthDate); } writer.Flush(); memoryStream.Seek(0, SeekOrigin.Begin); return new FileStreamResult(memoryStream, "application/octet

Custom login page for Windows Authentication when using IIS

我们两清 提交于 2021-02-19 08:34:39
问题 I am developing an intranet website application in ASP.NET Core 2.0 and trying to use Windows Authentication in conjunction with IIS, and then check the user against the authorised users in a database before the user can continue. The issue is, that the default browser pop-up is not really what is desired. Ideally, I want to use a custom login/logout page with this method, but I don't think it's possible. Alternative routes I have seen, are turning Windows Auth off, turning Anonymous auth on