asp.net-core-2.1

IDX20803: Unable to obtain configuration from

▼魔方 西西 提交于 2019-11-30 04:02:19
问题 I know this question has been answered, but I don't understand what people exactly do (about certificates, ssl) and they all use a localhost but not me. I used this sample as my example OpenIdConnect I'm using: A web app A web API Both are using .Net Core 2.1. The Web App is using the Azure AD connection to get a JwtBearer token, that is sent to the API. Seeing the route /api/information in the API, a request is sent from the Web App to the API, and the API is returning the error above. The

JWT cannot be retrieved by HttpContext.GetTokenAsync in .NET Core 2.1

限于喜欢 提交于 2019-11-29 15:19:38
This one really has me scratching my head as I can create a JWT. I can add an attribute to authorize a controller and see if I do not add an 'Authorization' 'Bearer (token)' to a header it will return a 401 unauthorized. However something as simple as getting the string of the token to get it's payload claims is not working. So this works fine: var token = Request.Headers["Authorization"]; This does not: var token2 = await HttpContext.GetTokenAsync(JwtBearerDefaults.AuthenticationScheme, "access_token"); I have change the signature, hooked up the IHTTPContextAccessor in startup like so:

.NET core 2.1 base href tag on Angular template

为君一笑 提交于 2019-11-29 12:23:38
I'm building a template for our team on top of the .NET Core 2.1 + Angular 5 template included in the latest release of core 2.1, we deploy applications into virtual folders, for example /it/myapp, or /aa/myotherapp On the 2.0 template the base href property would be set automatically, I'm assuming because it was built with razor, like this: <base href="~/" /> However this is not true for the 2.1 template, I'm assuming it's because the template actually only uses static files, with the new app.UseSpa() Any ideas on how I could automatically populate the base href tag? Thank you Yes, I know it

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

折月煮酒 提交于 2019-11-29 09:21:46
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 checks asp-fallback-test-class , asp-fallback-test-property , and asp-fallback-test-value . But what do

JsonResult return Json in ASP.NET CORE 2.1

痴心易碎 提交于 2019-11-29 09:10:59
Controller that worked in ASP.NET Core 2.0: [Produces("application/json")] [Route("api/[controller]")] [ApiController] public class GraficResourcesApiController : ControllerBase { private readonly ApplicationDbContext _context; public GraficResourcesApiController(ApplicationDbContext context) { _context = context; } [HttpGet] public JsonResult GetGrafic(int ResourceId) { var sheduling = new List<Sheduling>(); var events = from e in _context.Grafic.Where(c=>c.ResourceId == ResourceId) select new { id = e.Id, title = e.Personals.Name, start = e.DateStart, end = e.DateStop, color = e.Personals

Should HttpClient instances created by HttpClientFactory be disposed?

喜夏-厌秋 提交于 2019-11-29 06:59:44
So, I've registered a named client with the services collection in my Startup.cs: services.AddHttpClient(someServiceName, client => client.BaseAddress = baseAddress); and now can inject an IHttpClientFactory from my service provider. Using this IHttpClientFactory , I conjure up a client instance: var client = httpClientFactory.CreateClient(someServiceName) Once upon a time, it was necessary to be very careful about the disposing of HttpClient instances, as it was rarely the right thing to do . However, now we have HttpClientFactory , does this matter any more? Should/Can this client be

ASP.NET core 2.1 session

别说谁变了你拦得住时间么 提交于 2019-11-29 01:40:54
In ASP.NET core 2.1, I cannot access session variables. While debugging I have noticed that in every request the session ID changes (HttpContex.Session.Id) Did I make mistake in session configuration? Startup.cs public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether

Loading Razor Class Libraries as plugins

时光怂恿深爱的人放手 提交于 2019-11-28 11:49:17
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. Vahid Rassouli I had completely forgot about CompiledRazorAssemblyPart. What we need to do is: services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion

ASP.NET Core 2.1 + Kestrel (How to disable HTTPS)

∥☆過路亽.° 提交于 2019-11-28 06:41:17
So it appears with the advent of ASP.NET Core 2.1, Kestrel now automatically creates an HTTPS endpoint along side the HTTP one, and default project templates are setup to redirect from HTTP to HTTPS (which is easy enough to undo). However my question is... how can I disable HTTPS entirely for my project. I've read through the docs and played with a variety of config settings for HTTPS but nothing I do seems to allow me to turn it off and just run an HTTP project. Am I crazy or just missing something. I would expect this to be super easy to do. Abhishek Kumar If you are using Visual Studio 2017

.NET core 2.1 base href tag on Angular template

萝らか妹 提交于 2019-11-28 05:21:57
问题 I'm building a template for our team on top of the .NET Core 2.1 + Angular 5 template included in the latest release of core 2.1, we deploy applications into virtual folders, for example /it/myapp, or /aa/myotherapp On the 2.0 template the base href property would be set automatically, I'm assuming because it was built with razor, like this: <base href="~/" /> However this is not true for the 2.1 template, I'm assuming it's because the template actually only uses static files, with the new