asp.net-core

How to resolve generic interface to generic implementation when using dependency injection?

☆樱花仙子☆ 提交于 2021-02-11 13:01:36
问题 I have created a generic repository that I want to be used in a service. public abstract class AbstractBaseRepository<TEntity, TEntityKey> : IBaseRepository<TEntity, TEntityKey> where TEntity : class, IBaseEntity<TEntityKey>, new() { /* some code */ } And the interface: public interface IBaseRepository<TEntity, TEntityKey> { /* some code */ } On my service I inject the repository like this: public class TenantsService : AbstractBaseService<TenantEntity, int> { public TenantsService

EF Core with Cosmos DB provider, UserManager AddLoginAsync gives ConcurrencyFailure

岁酱吖の 提交于 2021-02-11 12:49:46
问题 Creating a new user, fetching the user again with usermanager for testing, and then using the method AddLoginAsync with the recently fetched user gives the error ConcurrencyFailure, Optimistic concurrency failure, object has been modified. When fetching the user the "ConcurrencyStamp" has the correct etag, but after the "AddLoginAsync" I can see the user object has an invalid etag, the ConcurrencyStamp is a GUID. I have followed the documentation and added this to the IdentityUser model

How to implement pagedList on DbQuery Entity in Dbcontext without fetching full data in .net core?

独自空忆成欢 提交于 2021-02-11 12:49:06
问题 I have to execute a sql string in .net core so first I added a Dbquery type entity in dbcontext. internal DbQuery<TempData> MyDataList{ get; set; } Then I fetched the data with my sql string as var data = context.MyDataList.FromSql(dataqueryString).ToList(); Iam getting the data correct but need to implement PagedList on this without fetching the whole data from database. I have tried like var data = context.MyDataList.FromSql(dataqueryString).ToPagedList(1,10) But this will fetch whole data

How to retrieve multiple images from Amazon s3 using one imagePath at once?

谁说胖子不能爱 提交于 2021-02-11 12:45:12
问题 I want to output every image inside the s3 bucket folder Business_Menu. Only way public async Task<(string url, Image image)> GetAWSPreSignedS3Url(entities.Cafe cafe, string mimeType, Constants.ImageType type) { AmazonS3Client s3Client = new AmazonS3Client(_appSettings.AWSPublicKey, _appSettings.AWSPrivateKey, Amazon.RegionEndpoint.APSoutheast2); string imagePath; string cafeName = trimSpecialCharacters(cafe.Name); var cafeId = cafe.CafeId; Image image; switch (type) { case Constants

What is the authentication/authorization scenario for web app that calls API without signed in user in azure AD?

久未见 提交于 2021-02-11 12:41:19
问题 I have web app written in react which is Single Page Application. Then I have back end API written in .NET core 3.1. As I mentioned earlier I have web app written in react so this react web app has to call one more API to read some configs. This third application is also a API application written in .NET core 3.1. As soon as web app spins up, it will call this third APP and read configs like API URL of second application and other azure related details. Now this third API app should be

How I can change configuration of HttpMessageHandler from Polly retry?

十年热恋 提交于 2021-02-11 12:40:49
问题 I have the following issue. I have a proxy set. If a request via proxy very slow or has crashed I would like to try again without proxy. For setting proxy I have the following code in the Startup.cs file: services.AddHttpClient<ICheckPackagesService, CheckPackagesService>(x => { x.Timeout = TimeSpan.FromSeconds(10); }).ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { Proxy = new WebProxy(IpService.GetIp()) }); But I can't imagine what I have to do for sending new one request

How I can change configuration of HttpMessageHandler from Polly retry?

一个人想着一个人 提交于 2021-02-11 12:40:10
问题 I have the following issue. I have a proxy set. If a request via proxy very slow or has crashed I would like to try again without proxy. For setting proxy I have the following code in the Startup.cs file: services.AddHttpClient<ICheckPackagesService, CheckPackagesService>(x => { x.Timeout = TimeSpan.FromSeconds(10); }).ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { Proxy = new WebProxy(IpService.GetIp()) }); But I can't imagine what I have to do for sending new one request

Placing a marker on google maps using asp.net-core razor pages

[亡魂溺海] 提交于 2021-02-11 12:35:43
问题 I have the following 3 pages in my project: Create.cshtml: @page @model AdminPortal.Web.Pages.Assets.CreateModel @{ ViewData["Title"] = "Create"; } <h1>Create</h1> <h4>Asset</h4> <hr /> <div class="row"> <div class="col-md-4"> <form method="post"> <div asp-validation-summary="ModelOnly" class="text-danger"></div> <div class="form-group"> <label asp-for="Asset.ID" class="control-label"></label> <input asp-for="Asset.ID" class="form-control" /> <span asp-validation-for="Asset.ID" class="text

Placing a marker on google maps using asp.net-core razor pages

北城以北 提交于 2021-02-11 12:34:35
问题 I have the following 3 pages in my project: Create.cshtml: @page @model AdminPortal.Web.Pages.Assets.CreateModel @{ ViewData["Title"] = "Create"; } <h1>Create</h1> <h4>Asset</h4> <hr /> <div class="row"> <div class="col-md-4"> <form method="post"> <div asp-validation-summary="ModelOnly" class="text-danger"></div> <div class="form-group"> <label asp-for="Asset.ID" class="control-label"></label> <input asp-for="Asset.ID" class="form-control" /> <span asp-validation-for="Asset.ID" class="text

How to configure an Azure website so that only specific users can access it

╄→尐↘猪︶ㄣ 提交于 2021-02-11 12:33:42
问题 I'm slowly getting up and running with ASP.NET Core web applications and I want to put my project online in order to be able to use it (and therefore know how to improve it) - also with mobile devices. But since I am at a learning stage where I am not aware of all the measures I should take to make it bullet-proof I want to secure my web application against possible misuse (at this point I have a pay-as-you-go plan and the usage is that low that it costs me only about one dollar per month). I