asp.net-core-2.0

User.Identity.Name is null in Asp.Net Core 2.x web application using Windows Authentication

爷,独闯天下 提交于 2020-01-17 00:26:48
问题 Problem When hosting an Asp.Net Core 2.0 or 2.1 Web Application behind IIS with Windows Authentication set to true, and Anonymous Authentication set to false, the User.Identity.Name property is null and User.Identity.IsAuthenticated is false. According to the documentation here, Windows Authentication should just work in Asp.Net Core 2.x when hosting with IIS. Background I'm in the process of migrating an Asp.Net 4.x MVC application over to Asp.Net Core following the Migrate from ASP.NET MVC

Multiple authentication schemes in ASP.NET Core

允我心安 提交于 2020-01-16 18:41:25
问题 Back in ASP.NET Core 1, authentication would be hooked manually into the request pipeline on its configuration: For a custom authentication process, you would simply define a AuthenticationMiddleware and hook it into your pipeline at the point where the authentication was supposed to happen. In ASP.NET Core 2, there's no more AuthenticationMiddleware and you're supposed to do a UseAuthentication() at some point in the pipeline where all authentication necessarily happens. The difference is

ASP.NET Core 2.0 - ASP.NET Identity - Invalid Token Error

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-16 18:07:09
问题 I am trying to confirm email from my users and it always works locally on development environment but it always fails in hosted server. I cannot RDP to this server and this is third-party server where I have subscribed. It gives "Invalid Token" error everytime. Nothing else. Is there any workaround for this ? Please advise. Thanks Adam This is how the code is generated and encoded. var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var newcode = HttpUtility.UrlEncode

CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file

淺唱寂寞╮ 提交于 2020-01-16 13:46:55
问题 net migrating from java in selfstudy mode.(visual studio 2019 community & SqlServer 2017 64bit community edition installed). I was following the instructions on this tutorial link When I executed the step of initial migration step I encountered this error when i run update-database I'm encountering this error. I know its related to database access/ configuration problem I'd really appreciate the correct way to provide it to Package Manager Console. I've added the allow service to interact

asp.net core with signalR < - > static socket

瘦欲@ 提交于 2020-01-16 11:59:09
问题 Use Case: I have a asp.net core web application with signalR core for messaging. :) Problem: I have to receive messages from a socket connection [via System.Net.Sockets] (machine with own socket communication) Is there any way to integrate the socket client in the web app (maybe Progamm.cs or Startup.cs?) And how can I get access to the signalR to forward the received message to the signalR Hub? thx 回答1: I suggest you to read the stockticker sample on : https://docs.microsoft.com/en-us/aspnet

Find API Status Codes for Controller ActionModel

…衆ロ難τιáo~ 提交于 2020-01-16 07:38:06
问题 Improving upon this question, how do I Find All the Existing Status Codes for ActionModel action in ApplicationModelProvider, before adding them? Currently looking through action.Filters[0].StatusCode in debugger, however cannot access the property in actual code. Need to see what Status codes already exist for API Controller Actions in all array list, before adding it . did filters[0] as a test Net Core API: Make ProducesResponseType Global Parameter or Automate foreach (ControllerModel

Cannot access Session object inside a helper class within my Asp.Net Core project

*爱你&永不变心* 提交于 2020-01-15 05:52:08
问题 I am trying to access the HttpContext.Session object in a helper class within my ASP.NET Core 2.1 project. When I try to access HttpContext.Session I get the following error. CS0120 An object reference is required for the non-static field, method, or property 'HttpContext.Session' With .NET 4.x ASP.NET, it was easily accessed with "HttpContext.Current.Session". Here is my class: public class MySession { public void Foo() { HttpContext.Session.SetString("Name", "The Doctor"); // will not work

How Do I Migrate Tenant Databases and Host Database in Asp.NET ZERO / Boilerplate?

本秂侑毒 提交于 2020-01-15 03:51:10
问题 I am using the ASP.NET ZERO framework with ASP.NET Core and Angular for my current project. I am also using the 'MultiTenancy - MultiDatabase' feature of ASP.Net ZERO. In application I have added a 'Tenant1-Database' connection string in create new Tenant. Now i have two databases: Host-Database Tenant1-Database When I create a new Tenant, 'Tenant1-Database' is automatically update as per previous migration files. But when I update the model with a new property and try to migrate the database

Dotnetcore container errors on startup asking if I mean to run SDK commands

╄→гoц情女王★ 提交于 2020-01-15 01:53:09
问题 I'm creating a simple dotnetcore 2.0 application and I want to containerize it. The idea being this container will run once on deployment to do some application configuration tasks. At present, the code just does this... class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } The docker file looks like this... FROM microsoft/dotnet:2.0-runtime ARG source WORKDIR /app COPY ${source:-obj/Docker/publish} . ENTRYPOINT ["dotnet", "consoleapp.dll"] I hit F5 in

HttpWebRequest in .NET Core 2.0 throwing 302 Found Exception

醉酒当歌 提交于 2020-01-14 07:28:18
问题 We are upgrading our application from .net framework to .net core 2.0. In it, we use a HttpWebRequest to contact a site with AllowAutoRedirect set to false. When the code executed request.GetResponse() The site will return a 302 response, which in .net framework is OK - you can take response and handle it (we are after the set-cookie header value). However, in .net core 2.0, a WebException gets thrown: The remote server returned an error: (302) Found. Is my understanding incorrect in that a