asp.net-core-2.1

VS2017 : Target framework drop down does not show .NET Core 2.1 option

☆樱花仙子☆ 提交于 2019-12-20 16:37:02
问题 I have already installed VS2017 Enterprise 15.6.4 . Recently installed .NET Core 2.1.101 SDK from official site I was expecting .NET Core 2.1 as one of the target framework available if I create console or asp.net core application. Can someone help me understanding what I am missing here. As suggested in comments, I installed 15.7 preview 2. Still no luck and same issue. 回答1: I have faced the same problem. I solved this by installing the right SDKs with Runtime for .NET Core 2.1. Basically to

Connection ID when calling SignalR Core Hub method from Controller

百般思念 提交于 2019-12-20 02:35:35
问题 This is a follow-up to another question and answer. What's the effect of calling HubContext.Clients.Caller or HubContext.Clients.Others from the controller? I see it depends on the connection ID. What value would it have in this situation? If the connection ID (and thus Caller and Others ) is invalid then (from within the controller action) how could I obtain a connection ID (for the client currently calling the Web API) that I could use with HubContext.Clients 's methods? 回答1: What's the

How do I set password options in Aspnet Core 2.1

*爱你&永不变心* 提交于 2019-12-19 19:52:31
问题 I have followed the SO example code and the official documentation but however I change the password length in my Aspnet core 2.1 project nothing changes. I always get the message "The Password must be at least 6 and at max 100 characters long." In public void ConfigureServices(IServiceCollection services) I have tried services.Configure<IdentityOptions>(options => { options.Password.RequiredLength = 1; }); in various places, or adding it to AddDefaultIdentity<> services.AddDefaultIdentity

ActionResult<IEnumerable<T>> has to return a List<T>

狂风中的少年 提交于 2019-12-18 12:55:22
问题 Take the following code using ASP.NET Core 2.1: [HttpGet("/unresolved")] public async Task<ActionResult<IEnumerable<UnresolvedIdentity>>> GetUnresolvedIdentities() { var results = await _identities.GetUnresolvedIdentities().ConfigureAwait(false); return results.ToList(); } I would have thought since GetUnresolvedIdentities() returns IEnumerable<UnresolvedIdentity> that I could just return return await _identities.GetUnresolvedIdentities().ConfigureAwait(false); Except I can't, as I get this

How do ASP.NET Core's “asp-fallback-*” CDN tag helpers work?

只谈情不闲聊 提交于 2019-12-18 04:36:22
问题 I understand what the asp-fallback-* tag helpers do. What I don't understand is how. For example: <link rel="stylesheet" href="//ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/css/bootstrap.min.css" asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css" asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" /> This loads bootstrap from the CDN, and loads the local copy if the CDN is down. But how does it decide to do that? I assume it

How to seed an Admin user in EF Core 2.1.0?

我怕爱的太早我们不能终老 提交于 2019-12-17 18:27:38
问题 I have an ASP.NET Core 2.1.0 application using EF Core 2.1.0. How do I go about seeding the database with Admin user and give him/her an Admin role? I cannot find any documentation on this. 回答1: As user cannot be seeded in a normal way in Identity just like other tables are seeded using .HasData() of .NET Core 2.1. Seed Roles in .NET Core 2.1 using code given below in ApplicationDbContext Class : protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating

Loading Razor Class Libraries as plugins

让人想犯罪 __ 提交于 2019-12-17 16:31:26
问题 When using Razor Class Libraries with ASP.net core 2.1, if I add reference to the class library, it loads controllers, and views as expected. But the question is, how can I load this modules dynamically at runtime? I want to put modules at directory, which are not referenced at design time, and load them at the start up of the app. I tried to use Application Parts. But that way, controllers are loaded, but views are not discovered. 回答1: I had completely forgot about CompiledRazorAssemblyPart.

Identity in ASP.Net Core 2.1 : Customize AccountController

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 07:13:05
问题 I have installed ASP.NET Core 2.1 but even though I have created a new ASP.NET Core Web Application using ASP.NET Core 2.1 with Individual User Accounts → Store user accounts in-app I can't find the AccountController or Views. I can still register and login without a problem but I can't find the code for it, it were present in 2.0. 回答1: One of the changes in 2.1 was Razor Class Libraries and the default identity lives in one of these in the individual auth templates. If you would like to have

TFS 2018 Build Fails with Core 2.1 and Microsoft.Windows.Compatibility 2.0.1

大憨熊 提交于 2019-12-14 03:28:25
问题 On prem TFS 2018 Build fails - New .Net Core 2.1 MVC project. add this package PM: Install-Package System.DirectoryServices -Version 4.5.0 Use TFS 2018 Build Agent: Build Fails. 回答1: After much research, the cproj file is hidden and you can only edit it via the menu in Visual Studio. Anyway, this file did not get Updated in TFS 2018 after adding the System.DirectoryServices package. Therefore, what the TFS 2018 Build server did was correct - looked at the cproj file and found assembly missing

.AspNetCore.Correlation. state property not found. Unknown Location

此生再无相见时 提交于 2019-12-13 20:41:31
问题 I am using hybrid authentication flow with OIDC. options.Events.OnRedirectToIdentityProvider = redirectContext => { if (redirectContext.Request.Path.StartsWithSegments("/api")) { if (redirectContext.Response.StatusCode == (int)HttpStatusCode.OK) { AuthenticationProperties properties = new AuthenticationProperties(); properties.RedirectUri = redirectContext.ProtocolMessage.RedirectUri; redirectContext.ProtocolMessage.State = options.StateDataFormat.Protect(properties); redirectContext.Response