asp.net-core

Can't access httpcontext extension methods in .net standard

你离开我真会死。 提交于 2021-02-17 02:01:49
问题 I have this .NET Standard library where I want to write a .NET Core middleware. Inside which I want to do : Endpoint endpoint = httpContext.GetEndpoint(); The GetEndpoint() extension method can't be resolved. I have referenced Microsoft.AspNetCore.Http and I have both Microsoft.AspNetCore.Http.Abstractions and Microsoft.AspNetCore.Mvc.Core packages added to the project. Is there a solution to this, am I missing something? 回答1: I assume you're writing a middleware for ASP.NET Core 3.1 since

.Net Core 3 Worker Integration Tests

你说的曾经没有我的故事 提交于 2021-02-16 20:14:11
问题 For integration testing Asp.Net Core application we have WebApplicationFactory. But how to test Worker ( HostedService ) that is not web application? I don't want to copy the whole DI configuration in SUT like in this question. Is it possible to use original configuration and override some of dependencies like we do for web application in WebApplicationFactory.WithWebHostBuilder? 回答1: I wasn't able to find any solution for Worker services integration testing hence I made adoption of

Add-Migration command only prompt “ScriptHalted”

巧了我就是萌 提交于 2021-02-16 16:31:27
问题 I'm trying to learn how to make App.Net Core application using Razor pages, using this tutorial : https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/model?view=aspnetcore-3.0&tabs=visual-studio After I made the Movie model and scaffold it successfully, I try to make the initial migration of the database. However, every time I'm using the command Add-Migration , it just prompts ScriptHalted , even when using the verbose option, same with Update-Database . I tried other commands

How to read/parse soap header request in WCF service created in .Net Core 3.1

99封情书 提交于 2021-02-16 15:09:58
问题 I have created a poc WCF service and i am able to call that service using SOAP UI or Postman. But for some project work, i need to parse the below soap security header SOAP Header <soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-5351BA8068B753C930158868612679914"><wsse:Username>test

How to read/parse soap header request in WCF service created in .Net Core 3.1

旧时模样 提交于 2021-02-16 15:09:46
问题 I have created a poc WCF service and i am able to call that service using SOAP UI or Postman. But for some project work, i need to parse the below soap security header SOAP Header <soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-5351BA8068B753C930158868612679914"><wsse:Username>test

Blazor base-tag and @page instruction in .razor files

我的梦境 提交于 2021-02-16 14:29:57
问题 I am getting started with Blazor server-side and I don't get the routing right. I don't understand the need for the base tag in _host.cshtml . If I still have to add the base url in every Blazor component, for example: I want to have a base address of /app/ and the @page directive for the example Counter with a value of "/counter" does not "compile" to "/app/counter" . I have to set the @page to "/app/counter" which makes sense but that means that the base Tag in _host.cshtml is useless...

Render a Partial View in _layout.cshtml using the partialview model instance with DBContext dependency injection

瘦欲@ 提交于 2021-02-16 13:37:04
问题 At first I'd like to say I'm new to Asp.net Core and also with concepts of dependency injection (DI). I'm reading a lot trying understand it, so I ask for patience. I'm trying Razor Pages (not MVC) and my goal is to render to "_layout.cshtml" a partial view, in which information obtained using the Entity Framework is available on all pages. I added the DBContext in the Startup.cs file as follows: services.AddDbContext <AppDBContext> (options => options.UseSqlServer (Configuration

Invalid state cookie. An error was encountered while handling the remote login. ASP.NET Core MVC external social login

旧时模样 提交于 2021-02-16 09:37:29
问题 While implementing external social login in ASP.NET Core2.2 MVC web application without ASP.NET Core Identity. I am getting below error while redirecting back to the application after successful sign in with Google, Facebook, Twitter, LinkedIn and Microsoft. An unhandled exception occurred while processing the request. Exception: Invalid state cookie. Unknown location Exception: An error was encountered while handling the remote login. Microsoft.AspNetCore.Authentication

Invalid state cookie. An error was encountered while handling the remote login. ASP.NET Core MVC external social login

喜夏-厌秋 提交于 2021-02-16 09:37:06
问题 While implementing external social login in ASP.NET Core2.2 MVC web application without ASP.NET Core Identity. I am getting below error while redirecting back to the application after successful sign in with Google, Facebook, Twitter, LinkedIn and Microsoft. An unhandled exception occurred while processing the request. Exception: Invalid state cookie. Unknown location Exception: An error was encountered while handling the remote login. Microsoft.AspNetCore.Authentication

Does EF Core 3.1 support DB First approach?

混江龙づ霸主 提交于 2021-02-16 04:01:10
问题 We are porting an ASP.NET MVC 4.x application to ASP.NET Core 3.1 . The current application is using EF 6.x DB first approach. As a part of this migration we are going to use EF Core 3.1 as an alternative to the current EF 6.x . So the question is: Does EF Core 3.1 support DB First approach? If not, what are the options? Are we left with only code first approach? Appreciate your helps. 回答1: Yes. It supports DB First Approach since .NET Core 1.0 until now. You need to download 4 from nugets