asp.net-core-2.2

ASP Core: how to configure area for api controller without AreaAttribute (or how to enable convention area routing for Api controller)?

99封情书 提交于 2019-12-11 17:56:31
问题 Razor Pages do not need any AreaAttribute and it is enough to place them into Areas/MyArea/Pages folder and this is enough to enable routing /MyArea/MyPage + My Proj + Areas + MyArea + Pages - MyPage.cshtml But when if I put API Controlller MyApi.cs to MyArea folder: + My Proj + Areas + MyArea + Pages - MyApi.cs then I am become forced to "hardcode" area name [Area("MyArea")] // !!! can't be missed [Route("[area]/api/[action]")] [Produces("application/json")] [ApiController] public class

ASP.NET Core 2.2 App Service hosted on Azure returning 500 without an exception being thrown

 ̄綄美尐妖づ 提交于 2019-12-11 16:48:26
问题 I have developed an App Service backend hosted on Azure using ASP.NET Core 2.2 . From time to time I'm getting a 500 status but I'm not able to find out where is that 500 being generated. I'm using application Insights and I see on Failed Requests that sometimes there are some calls to my App Service which are returning 500. If I reproduce that same call with same values with Postman I'm not getting any 500. There are also some End Client Apps making requests to this backend. I believe it's

Change email workflow in ASP.NET Core

佐手、 提交于 2019-12-11 14:54:40
问题 If a user wants to change to a new email address, I use: var token = await _userManager.GenerateChangeEmailTokenAsync(user, newEmail); ...and send a confirmation mail which includes this change token. The user clicks the link in the email, arrives back at the site, and now I need to change the email. BUT, I don't know the new email address. I've gone through the hassle of an confirmation mail loop, so I want to use it. Asking for the email again risks mistypings that could lock out the user

Integrating HealthCheck endpoint into swagger (open API) UI on dotnet core

我们两清 提交于 2019-12-11 11:29:52
问题 I am using Dotnet Core healthchecks as described here. In short, it looks like this: First, you configure services like this: services.AddHealthChecks() .AddSqlServer("connectionString", name: "SQlServerHealthCheck") ... // Add multiple other checks Then, you register an endpoint like this: app.UseHealthChecks("/my/healthCheck/endpoint"); We are also using Swagger (aka Open API) and we see all the endpoints via Swagger UI, but not the health check endpoint. Is there a way to add this to a

asp.net core identity does not redirect to correct logon pages

会有一股神秘感。 提交于 2019-12-11 10:59:22
问题 Configured this way it is not working. services .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.ExpireTimeSpan = TimeSpan.FromMinutes(5); options.LoginPath = $"/logon"; options.LogoutPath = $"/logoff"; options.AccessDeniedPath = $"/accessdenied"; options.SlidingExpiration = true; }) configured this way it is working : services.ConfigureApplicationCookie(options => { options.Cookie.Name = "Caldr.Auth"; options.LoginPath = $"/logon"; options

.net core docker is working via VS2019, but image build is getting error and not working

青春壹個敷衍的年華 提交于 2019-12-11 09:02:27
问题 "Docker": { "commandName": "Docker", "launchBrowser": true, "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/api/values", "httpPort": 52706, "useSSL": true, "sslPort": 44344 } This gives the output when it is run through visual studio But on build, it throws error DockerFile: FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base WORKDIR /app EXPOSE 83 EXPOSE 443 FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build WORKDIR /src COPY ["testdocker/testdocker.csproj",

ASP.Net Core MVC/API/SignalR - Change authentication schemes (Cookie & JWT)

陌路散爱 提交于 2019-12-11 02:28:31
问题 I've a .Net Core 2.2 web application MVC in which I've added API controllers and SignalR hubs. On the other side, I've a mobile app that calls the hub methods. Before calling hubs from the app, I am authenticating my users through an API call - getting back a JWT Token - and using this token for future requests, this way I can use Context.User.Identity.Name in my hub methods: public static async Task<string> GetValidToken(string userName, string password) { using (var client = new HttpClient(

Setup azure-pipelines.yml “Directory '/home/vsts/work/1/a' is empty.” with ASP.NET Core

坚强是说给别人听的谎言 提交于 2019-12-11 01:02:36
问题 I seriously need help to create my yml build file because I cannot find any good tutorial, sample or other king of help anywhere. I always get similar error: See the warning, it seems my build artifact is always empty. All step are succes but I cannot deploy because my files are not found. Stupid. ##[section]Starting: PublishBuildArtifacts ============================================================================== Task : Publish Build Artifacts Description : Publish build artifacts to

How does IHostingEnvironment.ContentRootPath get set?

百般思念 提交于 2019-12-10 23:02:57
问题 In my Azure Service Fabric Web API project, I am able to add my appsettings.json files to my config using this code in my Api.cs class: protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners() { return new ServiceInstanceListener[] { new ServiceInstanceListener(serviceContext => new KestrelCommunicationListener(serviceContext, "ServiceEndpoint", (url, listener) => { ServiceEventSource.Current.ServiceMessage(serviceContext, $"Starting Kestrel on {url}"); return

ASP.NET Core 2.2 (release) produces an error and stops w3wp

南笙酒味 提交于 2019-12-10 22:29:13
问题 Just upgraded one of our ASP.NET Core 2.1.5 projects to v 2.2 released today. After deploying to a production server it fails and shuts down a worker process. Project runs fine locally on Windows 10 (1803 / 17134.441) but not on production server. Windows Server 2016 (1607 / 14393.2639) with all the latest Windows Updates. I get the following error from IIS AspNetCore Module V2 : Could not find inprocess request handler. Captured output from invoking hostfxr: Process Id: 5688. File Version: