asp.net-core-webapi

Using Dependency Injection with .NET Core Class Library (.NET Standard)

北慕城南 提交于 2019-12-03 14:51:09
问题 I have gone through the link: https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/dependency-injection and learnt that how I can use dependency injection for Web API. As mentioned in the above link I can use Startup (Startup.cs) class for dependency injection inside API layer. But how can achieve dependency injection for the .NET Core Class Library. Below is the screenshot how I am adding a class library. And my project structure is In the project “DataManagement.Repository” I have

Why Authentication type - individual user accounts for Web API in .NET Core is not available when we creating new Web APi service

这一生的挚爱 提交于 2019-12-03 14:41:18
问题 Why it`s not possible to create Web API project with Individual User Accounts Authorization type? 回答1: UPDATE: All version numbers are updated from v1.2 to v2.0. Please find the ASP.NET Core Schedule and Roadmap: Identity Application Services A service layer will be added ASP.NET Core Identity and included in the project templates using Individual Authentication. This will allow authentication of users by way of JWT tokens such that Web APIs can be secured out of the box, and make it simpler

ASP.NET Core WebAPI Security Considerations

时间秒杀一切 提交于 2019-12-03 12:04:10
My WebAPI is, just that, an API backend for my UI to consume. In fact, I will have perhaps 10's of WebAPI services that my UI will use. I'm having difficulty understanding what I need to consider in terms of security. My APIs are secured using Bearer tokens, and allow https only. I have CORS set up and they only allow the origin https://my-front.end This all works great. However.. how can I protect against C/XSRF and replay attacks on a WebAPI? Do I even need to? Setting up anti-CSRF is rather painless with an ASP.NET MVC project, but how can you do it on a WebAPI one, from what I understand

Talking to IdentityServer4 with an Angular SPA application for authentication/authorization receiving a token then talking to Web API

橙三吉。 提交于 2019-12-03 11:35:55
问题 I have an asp.net core Web API. I am currently making calls directly to it using an Angular 4 app. I now want to add authentication and authorization layer. I would like to do this by adding another project (strictly for auth) of type : ASP.NET Core MVC (w/ Individual User Accounts) to my solution and then adding IdentityServer4 to it. The plan is to use the existing Identity tables to store users, roles, etc. Once this is all setup I am a bit confused about how my Angular 4 SPA app or any

What is the best practice in EF Core for using parallel async calls with an Injected DbContext?

…衆ロ難τιáo~ 提交于 2019-12-03 08:32:46
问题 I have a .NET Core 1.1 API with EF Core 1.1 and using Microsoft's vanilla setup of using Dependency Injection to provide the DbContext to my services. (Reference: https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro#register-the-context-with-dependency-injection) Now, I am looking into parallelizing database reads as an optimization using WhenAll So instead of: var result1 = await _dbContext.TableModel1.FirstOrDefaultAsync(x => x.SomeId == AnId); var result2 = await _dbContext

No Individual User Accounts auth option in ASP.NET Core Web API template

眉间皱痕 提交于 2019-12-03 08:19:55
问题 I am a bit confused as to why there is no Individual User Accounts authentication option in the latest ASP.NET Core Web API template. Is it still possible to implement individual user accounts the way that the MVC template does or would it not make sense? Let's say I am creating a stand-alone web API that is going to have all of my business logic and data layer that accesses the database which has the AspNet Identity tables. I plan on making calls to this API w/ an MVC app. I know one way of

ASP.net core web api: Using Facebook/Google OAuth access token for authentication

拈花ヽ惹草 提交于 2019-12-03 07:03:31
问题 For serveral days now I am trying to get OAuth authentication with Google and Facebook to work within my ASP.net core web api project. my current status is: I have an ASP.net core Web Api project in which the users need to be authenticated I have an angular 2 web app which should use my web api (with authentication) I have an android app, which should use my web api (with authentication) my goal is: Using Google/Facebook as OAuth providers for login later: adding own user accounts (probably

Using Dependency Injection with .NET Core Class Library (.NET Standard)

有些话、适合烂在心里 提交于 2019-12-03 04:36:10
I have gone through the link: https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/dependency-injection and learnt that how I can use dependency injection for Web API. As mentioned in the above link I can use Startup (Startup.cs) class for dependency injection inside API layer. But how can achieve dependency injection for the .NET Core Class Library. Below is the screenshot how I am adding a class library. And my project structure is In the project “DataManagement.Repository” I have written a class “UserRepository” and in the project “DataManagement.Repository.Interfaces” written an

How to properly integrate OData with ASP.net Core

可紊 提交于 2019-12-03 04:25:30
I'm trying to create a new ASP.NET Core project with a "simple" web api using OData and EntityFramework. I have previously used OData with older versions of ASP.NET. I have set up a controller with only a simple get function. I've managed to get it working with basic OData commands as filter and top, but I can't get the expand command working. I think it's because I can't quite figure out how to set it up in Startup.cs. I have tried a lot of things including following some odata samples from Github: https://github.com/OData/WebApi/tree/vNext/vNext/samples/ODataSample.Web https://github.com

Talking to IdentityServer4 with an Angular SPA application for authentication/authorization receiving a token then talking to Web API

大兔子大兔子 提交于 2019-12-03 02:03:23
I have an asp.net core Web API. I am currently making calls directly to it using an Angular 4 app. I now want to add authentication and authorization layer. I would like to do this by adding another project (strictly for auth) of type : ASP.NET Core MVC (w/ Individual User Accounts) to my solution and then adding IdentityServer4 to it. The plan is to use the existing Identity tables to store users, roles, etc. Once this is all setup I am a bit confused about how my Angular 4 SPA app or any other third party authenticates through the IdentityServer app. I would assume this then returns a token