asp.net-core-2.1

How to Make SignalR connection establishment When Login in Asp.net core 2.1 & Angular 6

拟墨画扇 提交于 2019-12-25 01:05:14
问题 I want to make SignalR connection establishment when login to system,now it's doing separately.In .net core I used Microsoft.AspNetCore.SignalR package and in angular I used @aspnet/signalr .When user connect with signalR,then that user want to store in a list with connectionId and username. Here is my login method in client side login(model: any) { return this.http.post(this.baseUrl + 'login', model).pipe( map((response: any) => { const user = response; if (user) { localStorage.setItem(

Azure DevOps Build fails for ASPNETCore 2.1 MVC application

*爱你&永不变心* 提交于 2019-12-24 18:43:09
问题 We are using Azure DevOps and we have a build pipeline which is continous integration. When I checkin my code into Azure DevOps branch my Build pipeline kicks on and it works good. Our company is new to .NET Core so as learning process I added ASP.NET Core 2.1 MVC application to my solution. Locally everything is working fine. When I check in my code my Azure DevOps build pipeline kicks off and it fails. Our build pipeline is VS Hosted 2017 agent. I get below errors in Azure DevOps The nuget

Razor Pages .NET Core 2.1 Integration Testing post authentication

三世轮回 提交于 2019-12-24 10:55:33
问题 I am looking for some guidance... I'm currently looking at trying to write some integration tests for a Razor Pages app in .net core 2.1, the pages I'm wanting to test are post authentication but I'm not sure about the best way of approaching it. The docs seem to suggest creating a CustomWebApplicationFactory, but apart from that I've got a little bit lost as how I can fake/mock an authenticated user/request, using basic cookie based authentication. I've seen that there is an open GitHub

Link ASP.Net Identity table to a user detail table

廉价感情. 提交于 2019-12-24 08:30:33
问题 I am trying to link my Identity user table to a user detail table I have created to track other user information. That user detail table is called UserProfile. I came across this link but it is not working in .NET Core 2.1: Link ASP.NET Identity users to user detail table Here is what I have currently: public class ApplicationUser : IdentityUser { [Key] public override string Id { get; set; } [ForeignKey("Id")] public virtual UserProfile UserProfile { get; set; } } [Table("UserProfile")]

Unit testing React components in ASP.NET Core project

自闭症网瘾萝莉.ら 提交于 2019-12-24 06:31:11
问题 I have managed to setup a basic React project using the React template in ASP.NET Core. I am not clear from the documentation and given this basic framework how I unit test individual components. I assume that I would use Jest and Enzyme to unit test the components but my efforts to set this up so far have failed. Let me list what I have done so far. 1) In the root of the project (above the ClientApp folder) I have created a tests folder. In that folder I have a single test named CancelButton

Unable to access a WebApi from a MVC Web app where both are secured by Azure AD B2C

最后都变了- 提交于 2019-12-23 15:39:33
问题 I have a web app (MVC) and a WebApi that are both secured by ADB2C in the same tenant. The web app wants to call the WebApi with a simple HttpClient. This is .NET Core 2.1 with the latest Visaul Studio project templates. The following points can be made: I can successfully sign in and sign up to the web app using B2C. I am soley using the new .NET Core 2.1 template where B2C is scaffolded into the project with minimum code. I create the WebApi project using the wizard also (this tiem for a

Get user id in ASP.NET Core 2

本秂侑毒 提交于 2019-12-23 13:07:53
问题 I'm trying to get the user id in an ASP.NET Core 2.1 MVC project. However, I was only able to get the email. I'm almost sure there has to be a 1/2 line way to get it (in the ASP.NET MVC membership it was just var loggedInUserId = User.Identity.GetUserId(); I tried so far like this: var loggedInUserId = User.Identity.ToString(); // Result = Name (E-mail) // var loggedInUserId = User.Identity.Name; // Result (E-mail) & this is now what I need 回答1: The old method of User.Identity.GetUserId() no

Where is the identity view?

核能气质少年 提交于 2019-12-23 09:55:57
问题 When I create a new project in .NET Core 2.1, I can not find the views behind /Identity/Account/Manage? Where is it, how do I change the page style now? 回答1: The views are now part of a precompiled library (Microsoft.AspNetCore.Identity.UI) being linked into the project, not separate pages. You can create the views yourself and they will override the library ones if needed. For more information see the Microsoft blog post. You can also scaffold the identity into the project. 来源: https:/

How to make Login page as a default route in ASP .NET Core 2.1?

*爱你&永不变心* 提交于 2019-12-23 09:29:30
问题 I am beginner in ASP .NET Core 2.1 and working on project which is using ASP .NET Core 2.1 with individual authentication. I want to make my login page as my default route instead of Home/Index: routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); Any help how can i change it as ASP .NET Core 2.1 as Login is now used as a razor page instead of MVC Action View. 回答1: Use this in ConfigureServices method. services.AddMvc().AddRazorPagesOptions(options=> {

Debugging Swashbuckle Error - Failed to load API Definition

北城余情 提交于 2019-12-23 09:22:15
问题 Is there any way to get a stack trace or inner exceptions on Swashbuckle/Swagger errors? At some point, it stopped working. I'm not sure if it was when I upgraded from .Net Core 2.0 to 2.1, but I'm pretty sure it was still working after that. When I navigate to myapidomain/swagger/index.html I get this error: Which is not very helpful. It was working 2 or so weeks ago... I didn't change any Swagger configuration. It's the same as it's always been: public void ConfigureServices