asp.net-core-2.0

How to consume a web service using .NET Core 2.0 Connected Services

依然范特西╮ 提交于 2021-02-08 07:24:03
问题 I have created a service called GetReportService. My endpoint is http://xxx1/usa/report.asmx. I am using POST passing a parameter id123. How do I invoke this web service using a web api in .NET Core 2.0? 回答1: I figured out that the connected service option is a WCF service so I am able to consume the service as I normally would in previous versions of .NET. However, in .NET Core if I want to inject that service, I do have to go to the Startup.cs file and add my service in the

.NET Core override controller level Authorize attribute for a specific action

≯℡__Kan透↙ 提交于 2021-02-07 20:43:04
问题 Here is an example controller to explain the case [Authorize] public class AccountController : ControllerBase { [AllowAnonymous] [Authorize(Policy = "SpecificPolicy")] public string MethodA() {} public string MethodB() {} } MethodA should only be authorized via "SpecificPolicy". MethodB should be authorized via the Authorized attribute The issue I'm having is that if I remove the AllowAnonymous attribute then Authorize on the controller takes precedence which I don't want for MethodA. When I

.NET Core override controller level Authorize attribute for a specific action

 ̄綄美尐妖づ 提交于 2021-02-07 20:42:38
问题 Here is an example controller to explain the case [Authorize] public class AccountController : ControllerBase { [AllowAnonymous] [Authorize(Policy = "SpecificPolicy")] public string MethodA() {} public string MethodB() {} } MethodA should only be authorized via "SpecificPolicy". MethodB should be authorized via the Authorized attribute The issue I'm having is that if I remove the AllowAnonymous attribute then Authorize on the controller takes precedence which I don't want for MethodA. When I

InvalidOperationException: No authentication handler is registered for the scheme Bearer.

痞子三分冷 提交于 2021-02-07 20:13:44
问题 I am trying to implement Aspnet.security.openidconnect (ASOS) with .net core 2.1 I can successfully generate access_token and refreshtoken using ASOS but when I am adding Authorize Attribute on any of my action and try to call that action with postman I am getting following exception: InvalidOperationException: No authentication handler is registered for the scheme Bearer. The registered schemes are: ASOS. Did you forget to call AddAuthentication().Add[SomeAuthHandler Here is the code:

InvalidOperationException: No authentication handler is registered for the scheme Bearer.

痞子三分冷 提交于 2021-02-07 20:02:10
问题 I am trying to implement Aspnet.security.openidconnect (ASOS) with .net core 2.1 I can successfully generate access_token and refreshtoken using ASOS but when I am adding Authorize Attribute on any of my action and try to call that action with postman I am getting following exception: InvalidOperationException: No authentication handler is registered for the scheme Bearer. The registered schemes are: ASOS. Did you forget to call AddAuthentication().Add[SomeAuthHandler Here is the code:

Azure AD as an “external provider”?

为君一笑 提交于 2021-02-07 08:39:46
问题 I'm trying to build a simple ASP.Net Core 2.2 web app that allows AzureAD as an "external provider". I'm doing this in Visual Studio 2019. As a super-simple demo project, I started by creating a new project that uses Azure AD as the login provider: Select ASP.NET Core Web Application Select Web Application (Model-View-Controller) Change Authentication to "Work or School Accounts". It automatically filled in my domain name (because I'm logged in to VS) This creates a web application set up to

Azure AD as an “external provider”?

我只是一个虾纸丫 提交于 2021-02-07 08:39:27
问题 I'm trying to build a simple ASP.Net Core 2.2 web app that allows AzureAD as an "external provider". I'm doing this in Visual Studio 2019. As a super-simple demo project, I started by creating a new project that uses Azure AD as the login provider: Select ASP.NET Core Web Application Select Web Application (Model-View-Controller) Change Authentication to "Work or School Accounts". It automatically filled in my domain name (because I'm logged in to VS) This creates a web application set up to

Asp.net Core 2.0 Static files not found error

 ̄綄美尐妖づ 提交于 2021-02-07 07:27:18
问题 Hi guys I am trying to create an ASP.net Core 2.0 web application; I have placed the static files in a folder called Content. I am giving the following path: <link href="@Url.Content("../Content/css/style.css")" rel="stylesheet"> I am getting a 404 - not found error when loading the view. However the GET request path is correct and the file exists in the same path. This is the path to which the GET request is being done: http://localhost:49933/Content/css/style.css I found solutions that

Multiple Implementations of IHostedService

你。 提交于 2021-02-07 02:58:55
问题 I'm trying to create background services using IHostedService. Everything works fine if I only have ONE background service. When I try to create more than one implementation of IHostedService only the one that was registered first actually runs. services.AddSingleton<IHostedService, HostedServiceOne>(); services.AddSingleton<IHostedService, HostedServiceTwo>(); In the above sample StartAsync on HostedServiceOne gets called but StartAsync on HostedServiceTwo never gets called. If I swap the

Not creating database using Migration command Update-Database in ASP.Net Core 2

ⅰ亾dé卋堺 提交于 2021-02-06 04:26:32
问题 I created new ASP.Net core project with WebAPI. Using the below link. jwt-authentication-with-aspnet-core-2-web-api-angular-5-net-core-identity-and-facebook-login I have to use add-migration update-database manually. Here I add one thing more that I don't know how to debug app in VS Code. After created my project in VS Code I open my project in Visual Studio 2017. When I about to run the update command Update-Database in Package Manager Console. I encounter below error also in my