asp.net-core-2.0

NuGet References within same solution

戏子无情 提交于 2019-12-12 12:26:43
问题 This may have already been asked before (if so provide links please). I am working on a 'core' solution set for my company. We have several different projects in this solution set. Each project when built is turned into a NuGet Package to be used in our other solutions projects. What I am finding is I want to reference some of the projects in the 'core solution' with other projects in the 'core solution' via NuGet (verse using project references) so that when pushed to our NuGet, all packages

How to determine which port ASP.NET Core 2 is listening on when a dynamic port (0) was specified

孤街醉人 提交于 2019-12-12 08:38:46
问题 I've got an ASP.NET Core 2.0 app which I intend to run as a stand-alone application. The app should start up and bind to an available port. To achieve this I configure the WebHostBuilder to listen on "http://127.0.0.1:0" and to use the Kestrel server. Once the web host starts listening I want to save the url with the actual port in a file. I want to do this as early as possible, since another application will read the file to interact with my app. How can I determine the port the web host is

What exactly is 'UseAuthentication()' for?

試著忘記壹切 提交于 2019-12-12 07:39:16
问题 I have a question regarding authentication in ASP.NET Core 2: what exactly is the call app.UseAuthentication() for? Is it a basic prerequisite so that I can implement my custom authentication logic? I already had a look at the implementation of UseAuthentication and also of the actual middleware AuthenticationMiddleware, but to be honest, I don't understand what that is actually doing and why it would be necessary. To put it in another way: Do I need to call UseAuthentication() or is it a

Localization Files in Asp.Net Core

雨燕双飞 提交于 2019-12-12 05:00:12
问题 I don't have much experience working with resource files, but the little that I have is from Web Forms. There from what I can tell is you create a resource file called let's say InternalMessages.resx and then you create a Spanish version Errors.es.resx. Now if I have set up my code correctly for choosing language, all I have to do it call InternalMessages.MyMessage and it will choose the right language, regardless of what page you are on. In core, this concept doesn't seem to work. no matter

PDF file download from byte[]

邮差的信 提交于 2019-12-12 01:16:20
问题 I've been working to do a PDF file download from bytes[] in ASP.Net MVC C#. The below code is working fine. I need to convert the code to .NET Core for the same PDF download process. string fileName = "testFile.pdf"; byte[] pdfasBytes = Encoding.ASCII.GetBytes(fileBytes); // Here the fileBytes are already encoded (Encrypt) value. Just convert from string to byte Response.Clear(); MemoryStream ms = new MemoryStream(pdfasBytes); Response.ContentType = "application/pdf"; Response.Headers.Add(

.net core 2.0 cookie authentication getting stuck in infinite redirect loop when trying to access over https

痴心易碎 提交于 2019-12-11 23:24:27
问题 I have just moved my code to our QA environment which uses https and what was working in Dev is not working in QA because the browser gets stuck in an infinite redirect loop. Our load balancer forces https so when the login redirect happens from code, which for some reason it's trying to redirect to http instead of https, the load balancer is stopping it and adding https again which causes the infinite loop. The question I have is why is this code not just redirecting to https, the path is

OAuthAuthorizationProvide vs Aspnet.security.openinconnect

隐身守侯 提交于 2019-12-11 18:15:59
问题 I have tried implementing ASOS with .net core 2.1 and there were few things which were available in OAuthAuthorizationProvider but I couldn't find them in ASOS. Also I think the context is little different in ASOS, So is there any alternate of the following code in ASOS: OAuthBearerOptions = new OAuthBearerAuthenticationOptions(); var options = new OAuthAuthorizationServerOptions { AuthorizeEndpointPath = new PathString(AuthorizePath), TokenEndpointPath = new PathString(TokenPath),

How to validate only a part of Model State in asp.net core 2 web api

社会主义新天地 提交于 2019-12-11 17:53:31
问题 We are using a Usermaster DTO in 2 different projects. public class UserMaster : BaseProperties { [BsonElement] [BsonRequired] [Required] public string FirstName { get; set; } [BsonElement] [BsonRequired] [Required] public string LastName { get; set; } [BsonElement] [BsonRequired] [EmailAddress] [Required] public string EmailId { get; set; } [BsonElement] [BsonRequired] [DataType(DataType.Password)] [Required] public string Password { get; set; } [BsonIgnore] [DataType(DataType.Password)]

.Net Identity 3 on existing solution

南笙酒味 提交于 2019-12-11 17:43:49
问题 I believe that .NET Identity 3 cannot run on an existing (v4.5) ASP.NET solution, but requires .NET Core. I cannot update to .NET Core. Is there a workaround for this? If not then how are people supposed to migrate from ASP.NET Membership to ASP.Net Identity? 回答1: First of all, I need to note that ASP.NET Core (which works with Identity 3) does not require .NET Core. It can be used either over .NET Core or .NET Framework 4.6.1 (or higher). I guess you use the default approach in both cases

Asp.Net Core 2 SignalR Ubuntu Xamarin Android

大兔子大兔子 提交于 2019-12-11 17:28:55
问题 I have deployed Asp.Net Core 2 website on ubuntu with Nginx as a reverse proxy. The website works but SignalR doesn't. Same build work locally in IIS-Express. Getting following error in logs, Terminating Long Polling connection by sending 204 response. Following nginx configuration I am using, server { listen 80; location / { proxy_pass http://localhost:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host;