asp.net-core-2.1

Alternative of thread.Abort() in Asp.net Core?

纵然是瞬间 提交于 2021-01-29 07:28:41
问题 Is there any alternative option for thread.Abort() in asp.net core as it no longer support with .Core. // Exceptions: // T:System.PlatformNotSupportedException: // .NET Core only: This member is not supported. This is throw PlatformNotSupportedException exception. I used thread.Interrupt() but it not work as per expectation. 回答1: Thread.Abort() has been removed, since it could not be reliably ported to all platforms and in general poses a threat to the entire app domain, when used incorrectly

Getting “The inner stream position has changed unexpectedly” in AWS Lambda

房东的猫 提交于 2021-01-28 11:38:49
问题 I am implementing a file upload in ASP.Net core. Everything works fine when testing locally on Windows but when I deploy my code on AWS Lambda, I am getting "System.InvalidOperationException: The inner stream position has changed unexpectedly. at Microsoft.AspNetCore.Http.Internal.ReferenceReadStream.VerifyPosition() at Microsoft.AspNetCore.Http.Internal.ReferenceReadStream.Read(Byte[] buffer, Int32 offset, Int32 count) at System.IO.Stream.CopyTo(Stream destination, Int32 bufferSize)" My code

Setting expiration for IDistributedCache.SetAsync while using AddDistributedRedisCache

白昼怎懂夜的黑 提交于 2021-01-27 12:11:08
问题 I am using .net core api (2.1) with aws redis cache. I don't see a way to set expiration to the IDistributedCache.SetAsync. How is it possible? My code segment is below: // Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddDistributedRedisCache(options => { var redisCacheUrl = Configuration["RedisCacheUrl"]; if (!string.IsNullOrEmpty(redisCacheUrl)) { options.Configuration = redisCacheUrl; } }); } //Set & GetCache public async Task<R> GetInsights<R>(string

OpenIdConnect Correlation Cookie not found when user click link from Office application

拜拜、爱过 提交于 2021-01-27 12:09:05
问题 I have an app that is authenticating with Azure Active Directory using OpenIdConnect. Everything is working fine except when I link to my site from a Office Application (excel/ word). From these applications I get a "Exception: Correlation failed.". From my research it seems to be that office is first doing the 302 redirect and then opening that page not the original link. See: https://github.com/aspnet/Security/issues/1252 After a recommendation for how to handle this scenario. I don't want

OpenIdConnect Correlation Cookie not found when user click link from Office application

落花浮王杯 提交于 2021-01-27 12:02:16
问题 I have an app that is authenticating with Azure Active Directory using OpenIdConnect. Everything is working fine except when I link to my site from a Office Application (excel/ word). From these applications I get a "Exception: Correlation failed.". From my research it seems to be that office is first doing the 302 redirect and then opening that page not the original link. See: https://github.com/aspnet/Security/issues/1252 After a recommendation for how to handle this scenario. I don't want

Setting expiration for IDistributedCache.SetAsync while using AddDistributedRedisCache

放肆的年华 提交于 2021-01-27 12:00:53
问题 I am using .net core api (2.1) with aws redis cache. I don't see a way to set expiration to the IDistributedCache.SetAsync. How is it possible? My code segment is below: // Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddDistributedRedisCache(options => { var redisCacheUrl = Configuration["RedisCacheUrl"]; if (!string.IsNullOrEmpty(redisCacheUrl)) { options.Configuration = redisCacheUrl; } }); } //Set & GetCache public async Task<R> GetInsights<R>(string

Tips for running IdentityServer4 in a web farm

自闭症网瘾萝莉.ら 提交于 2021-01-27 07:27:23
问题 Does anyone have experience with running IdentityServer4 in a web farm (multiple IIS servers) behind a load balancer? We've had some issues getting 2 servers to work together. I didn't see a deployment guide for IdentityServer4. There is one here for IdentityServer3. https://identityserver.github.io/Documentation/docsv2/advanced/deployment.html We have implemented the DataProtection in the Startup.cs. StackExchange.Redis.ConnectionMultiplexer connectionMultiplexer = RedisConnectionFactory

Null response returns a 204

♀尐吖头ヾ 提交于 2021-01-26 23:53:17
问题 My controller returns a 204 when I do a GET request and I don't find any data. [Route("user/v1/[controller]")] public class UserLoginController : Controller { [HttpGet] public async Task<UserLogin> Get(int userId) { var userLoginLogic = new UserLoginLogic(); return await userLoginLogic.GetUserLogin(userId); } } This is only for GET requests, POST, PUT, DELETE return a 200 empty response. This messes with my swagger definition which has a response defined for a 200 response, and I would rather

Is it possible to automatically map a DB view on Entity Framework Core version 2.1?

大兔子大兔子 提交于 2021-01-23 11:10:38
问题 I found this interesting question on stackoverflow about mapping a view and working with it in EF Core. According to its answer, with previous EF Core versions wasn't possible to automatically map views. But what now? According to the Entity Framework 2.1 Roadmap, An EF Core model can now include query types. Unlike entity types, query types do not have keys defined on them and cannot be inserted, deleted or updated (i.e. they are read-only), but they can be returned directly by queries. Some

ASP.NET Core Web API runs locally but not on Azure app service

北城余情 提交于 2021-01-05 12:00:20
问题 I have been following this link exactly (https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-2.2&tabs=visual-studio) to create my web api. **Locally, it is working fine. Tested the links and it returned JSON data However, once I deploy my web api up to azure app service, all my api links have been returning me error 404. Is there anything that I might have missed out for routing? In my controller I have added this to my head. [Route("api/xxx")] [ApiController]