asp.net-core-2.0

How to check success of HubConnection.StartAsync in SignalR for ASP.NET Core 2.0?

ぃ、小莉子 提交于 2019-12-11 00:19:04
问题 Using SignalR for ASP.NET Core 2.0, Client side (1.0.0-alpha2-final), C# VS2017. To connect the code is: await hubConnection.StartAsync(); since this is an await for a void how can we test if the client did manage to connect ? In my tests I have a breakpoint on the server side in public override async Task OnConnectedAsync() but that breakpoint is not always hit therefore I know that sometimes the client does not connect. Or perhaps it did connect but OnConnectedAsync() was not triggered? How

.NET Core app with Azure App Service Authentication

冷暖自知 提交于 2019-12-11 00:03:55
问题 My webapp is developed with .NET Core and deployed in Azure. I have enabled Azure App Service Authentication and configured it to use Azure Active Directory. When I access the webapp I do get redirected to the correct login-page. After I login I can browse to the endpoint .auth/me and see that claims exists for my user. I can also verify that the request headers below exists with values: X-MS-TOKEN-AAD-ID-TOKEN X-MS-TOKEN-AAD-ACCESS-TOKEN X-MS-TOKEN-AAD-EXPIRES-ON X-MS-TOKEN-AAD-REFRESH-TOKEN

ASP.NET Core 2.0 site POST request resulting in 404 on Azure

风流意气都作罢 提交于 2019-12-10 20:56:34
问题 I've just upgraded an ASP.NET Core 1.1 web application to 2.0 and tested without issue locally. However, when the site is deployed to Azure a POST request that worked locally results in a 404 (I guess this could be the same for all POST requests, but I'm unable to log-in due to the issue). Any ideas why this might fail to be working when deployed to Azure but working perfectly when run through IIS Express locally? I deleted the original deployment slot on Azure and re-created as initially

Angular CLI 6 - ng build doesn't produce Server bundles

非 Y 不嫁゛ 提交于 2019-12-10 20:10:05
问题 I am following the official Angular Universal guide available at https://angular.io/guide/universal but when I run ng build --prod it does produce client bundles but doesn't produce server bundles. Since my environment is ASP.Net Core, I have skipped Universal Webpack configuration and server.ts . With previous version of Angular CLI we were able to build server bundle by specifying app while building ng build --app=ssr Am I missing something? Can anyone please help? 回答1: Fix: One thing

How to trigger login for IdentityServer4 without accessing secure page in the MVC app?

早过忘川 提交于 2019-12-10 19:45:27
问题 In the docs http://docs.identityserver.io/en/release/quickstarts/3_interactive_login.html it says " Trigger the authentication handshake by navigating to the protected controller action ". This would be by simply accessing any action in your MVC site with [Authorize]. After signin, this would redirect to the page they were trying to access, not to the page they last visited (which is good, expected behavior). Great. But what about this scenario? User is in some anonymous part of the site.

.net core 2.1 “POST” an IFormFile using Postman - the application completed without reading the entire request body

末鹿安然 提交于 2019-12-10 18:38:00
问题 I'm working on a dotnet core WebAPI 2.1 and I can't find a way of sending to into the Body an image. The controller looks like this: [HttpPost("api/image")] public IActionResult Post([FromBody]IFormFile file) { var filePath = Path.GetTempFileName(); if (file.Length > 0) { return Ok(); } return BadRequest(); } And this is my Postman call: This call is never finishing as the Kestrel is failing I've already tried to use Consumes [Consumes("application/json", "application/json-patch+json",

GetExternalLoginInfoAsync returns null dotnet core 2.0

…衆ロ難τιáo~ 提交于 2019-12-10 18:36:24
问题 I'm trying to setup Facebook authentication with dot-net core 2.0, but in my ExternalLoginCallbackAsync method, I'm always getting null as a response I have followed the documentation and so far this is what I've done: in my ConfigureServices in the startup file: services.AddAuthentication( options => options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme); services.AddAuthentication().AddFacebook( f => { f.AppId = Configuration["facebook-app-id"]; f.AppSecret =

How to remove extra spaces in input model in dot net core?

孤街醉人 提交于 2019-12-10 18:28:38
问题 I have found a link to remove extra spaces in the model properties which is string type How to trim spaces of model in ASP.NET MVC Web API How to achieve the same functionality in dot net core 2.1 web api? Or is there any build in formatters available in dotnet core for removing extra spaces in input and output model? Thanks in advance? 回答1: I believe the answer you linked is probably your best option. So create a converter as per the anwser. class TrimmingConverter : JsonConverter { public

No service for type 'Microsoft.AspNetCore.Hosting.IHostingEnvironment' has been registered

亡梦爱人 提交于 2019-12-10 18:25:11
问题 I have a problem when I want to fire add-migration command for a ASP MVC Core 2 project. No service for type 'Microsoft.AspNetCore.Hosting.IHostingEnvironment' has been registered. Here is my Startup.cs: public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; set; } public void ConfigureServices(IServiceCollection services) { services.AddDbContextPool<SampleArchContext>((serviceProvider, optionsBuilder)

dotnet core 2.1: “Found conflicts between different versions of” when referencing a web project from an xunit project

梦想与她 提交于 2019-12-10 18:21:03
问题 I was on my way to upgrade a netcore 2.0 app to 2.1 when I stumbled upon this strange thing. If I create a web project, and then a xunit project referencing the first one, as soon as I use any Newtonsoft.Json class I get the following error: /media/data/sas/devel/opt/dotnet-sdk-2.1.401/sdk/2.1.401/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3277: Found conflicts between different versions of "Newtonsoft.Json" that could not be resolved. These reference conflicts are listed in