Questions tagged [asp.net-core-middleware]

17585 questions
1

votes
1

answer
3.1k

Views

Connection ID required

I am trying to build a simple chat application using SignalR with ASP.NET Core 2.0. The problem is that when I want to access one of my hub's url (localhost:5000/chat) I receive as a response: Connection ID required with error code 400. I am using auto generated from template authentication (users...
Georgi Stoimenov
1

votes
2

answer
376

Views

Dynamically return fields from a web method

I have a WebAPI service where I would like to allow users to specify which fields they'd like returned. For example, say I have the following Person class: public class Person { public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } } and that ca...
Phillip Copley
1

votes
3

answer
4.5k

Views

.net core cross platform desktop app

I'd like to develop a cross platform desktop app by using .net Core. The app needs to be executed on linux, mac os, and windows. For that purpose, should i create a console app and put below lines in settings xml? win10-x64;osx.10.12-x64;debian.8-x64 Will it be sufficient? If so, should i write all...
Dilara Albayrak
1

votes
1

answer
1.8k

Views

Generate Razor HTML emails in dotnet core 2

How can you generate emails (html) using Razor in dotnetcore - and not from an MVC app (think from a console app)? RazorEngine does a great job in .net 4.x, but is not working in dotnet core. RazorEngineLight works in dotnet core 1.x, but not in 2.x. Some other options are mentioned in this post: Us...
Kjensen
1

votes
2

answer
928

Views

Changing B2C Reply URL from “signin-oidc” to something else does not work

I am trying to get a ASP.NET Core 2.1 web app running with Azure AD B2C. I have this running after much reseach (and more trial and error) as the instructions found in the docs are a little off. The sign-in/sign-up process works using the default scaffolding during the project setup wizard, plus the...
John
0

votes
0

answer
13

Views

How to bring another project (get,post) api method to swagger api project?

I've created one API project with asp.net core in which I used swashbuckle.AspNetCore dll to generate swagger. It is working perfectly and going well. Now I have another c#(.net standard library) in which I have created some GET, POST, DELETE, PUT method. Need to load all of those methods to the swa...
sk5202
0

votes
0

answer
12

Views

Force inner join from EF Cores Include() on optional relationship

We changed a relationship from required to optional, now the resulting SQL produced by EF Core's Include() does a left outer join rather than inner join. Problem is that those optional entities have query filters on them that is required. Let's say we have the following; public class First { public...
HenrikM
1

votes
0

answer
9

Views

The selector “app-root” did not match any elements after update to Angular 7

After updating the client app of an ASP.Net Core MVC SPA-project from Angular 5.2 to Angular 7, I receive the following runtime error when loading the app from index.html: The selector 'app-root' did not match any elements at DefaultDomRenderer2.push../node_modules/@angular/platform-browser/fesm5/pl...
Marc
1

votes
2

answer
1.9k

Views

How to read connection string inside .NET Standard Class library project from ASP.NET Core

In my solution, I have a ASP.NET Core web project and a .NET Standard class library project. Class library project is the data access layer and I want to read the connection string from my appsettings.json (ASP.NET Core project) in my data access layer. I have found few answers such as by Andrii Li...
Learning Curve
1

votes
2

answer
670

Views

Which files to publish? ASP .Net Core 2.0

I'm working on hosting my first ever Asp.net core 2.0 website. To bundle the project I ran 'dotnet publish' This created the following folder structure for publish: /wwwroot /appsettings.Development.json /appsettings.json /ProjectName.deps.json /ProjectName.dll /ProjectName.pdb /ProjectName.PreCompi...
Richard Smith
1

votes
2

answer
192

Views

Options for controlling Destructuring of request object

I've run into a problem that I'm struggling to find a clean solution for, and Googling has not made me any wiser. The situation (1) We have our own assembly for setting up and adding a Serilog logger to any of our projects (consistent logging output, theme, etc) and this assembly has no references t...
Mashton
1

votes
2

answer
188

Views

Is it able to store Firebase user to our own database?

If I use the user registration and login through the firebase authentication, the user information are stored in the firebase database side. How can I get the user information (such as FirstName, LastName, Gender and etc.) and store in my own database? Is it use the access token to call my API to ch...
ZhengJie Tan
1

votes
2

answer
713

Views

HttpContext.Features vs HttpContext.Items In Asp.Net Core

What is the differences between this two Properties? I can use HttpContext.Items instead of HttpContext.Features to share data between middlewares. The only difference i see is that i tell Items for a key and it gives me object and i have to cast it. This casting can be done in Features automaticall...
Mohammad Barbast
1

votes
2

answer
654

Views

ASP.NET Core ViewData, BindProperty or TempData?

In ASP.NET Core Views and Razor Pages we can use: public class LoginModel { [BindProperty] public bool DisplayCaptcha { get; set; } // OR [ViewData] public bool DisplayCaptcha { get; set; } // OR [TempData] public bool DisplayCaptcha { get; set; } } To share data between View/Page/Controller... But...
Vanderlei Pires
1

votes
1

answer
1.8k

Views

My ASP.NET Core app says it can't read web.config

I get this error when I access my app which I published to local IIS: HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid. My web.config is really simple: What could be wrong? I tried giving all users permissi...
ekolis
1

votes
1

answer
456

Views

asp.net core 2.1 with knockout

I've been trying to teach myself the ins and outs of .NET Core development, and I've got the start of a Core 2.1 web application created. I've even gotten the hang of EF Core, and have a working DB Context. I am, however, having difficulty figuring out how to implement knockout. I ran the command do...
Kurt
1

votes
2

answer
699

Views

asp.net core hosted service sleeps after api inactivity

I have a hosted service that checks an email account every minute. I also am using MVC with Web API 2.1. In order to get my hosted service to start, I have to 'wake it up' by calling API methods. After a period of inactivity from the Web API the hosted service goes to sleep and stops checking the...
Cindy Hoskins
1

votes
1

answer
607

Views

ASP.NET Core Disable CORS for specific controllers

I have different set of controllers in my application (let's say A and B). CORS for A controller needs to be enabled and disabled for B controllers. I have configured CORS via the policies in the following way: ConfigureServices method: services.AddCors( options => { options.AddPolicy( 'AllowCors',...
Pylyp Lebediev
1

votes
1

answer
249

Views

TempData isn't persisting data on Production Server [ASP.NET CORE 2.1]

I have an issue and I have searched the docs to see maybe I made a mistake or something but didn't find the answer that I was looking for. My issue is this, After saving a product, I use the PRG(Post-Redirect-Get) pattern so the user doesn't resubmit the form when pressing the browser back button. I...
umeh oscar
1

votes
1

answer
528

Views

ASP.NET Core: IConfigurationBuilder Does Not Contain Definition For AddAzureKeyVault

I am upgrading my ASP.NET Core web app to .NET Core 2.1, but am getting the following error: IConfigurationBuilder Does Not Contain Definition For AddAzureKeyVault This code works in .NET Core 2.0. It looks like a library is missing in .NET Core 2.1. using System; using Microsoft.AspNetCore; using M...
Brandon Minnick
1

votes
1

answer
223

Views

Override AccountController in Individual User Accounts

I've created in Asp .Net Core 2.1 - mvc Individual User Accounts and add scaffold identity. I need override route Identity/Account/Register to Account/Register. I guess I need access in AccountController and add attr [Route('')]. How can i do it?. In advance thanks for help.
nikita Abramov
1

votes
1

answer
219

Views

How to copy a csproj file using docker without visual studio and without docker compose?

I just started a new solution with a .NET Core Project (2.1) using visual studio 15.8.8. It can run and debug it by setting the docker compose file as a startup project. It works! Logically, I should be able to build the docker image with a simple commandline statement. However, it complains that th...
Daan
1

votes
1

answer
960

Views

How to update appsettings.json based on publish profile using .NET Core?

I'm currently making the switch from .NET Framework to .NET Core. In the past, all of my application settings were in the Web.config file. When I added a new publish profile, I could right click and select 'Add Config Transform' which would generate a nested Web.{Profile}.config file under Web.confi...
Matthew
1

votes
2

answer
494

Views

Change Id type of asp.net core 2.2 IdentityUser

I'm new to dot-net core 2.x, so... I would like to change the type of the Id in asp.net core 2.2 IdentityUser from string to int. All the examples I've found via google (and the stackoverflow search facility) are giving me examples of asp.net core 2.0 which provides an ApplicationUser when you scaff...
Owen
1

votes
1

answer
458

Views

Configure log4net AdoNetAppender in asp.net core application

I am trying to configure log4net using MicroKnights AdoNetAppender(nuget 3rd party library) for my asp.net core application. However nothing is getting logged in database. Also I am not getting any errors when running the application. I suspect the connectionType is causing the trouble. log4net conf...
user2443401
1

votes
1

answer
454

Views

ASP.NET Core 2.1 Role Manager Register

In my seeding code I create Users and Roles, and the error seems to be whenever I run it through startup I seem to be getting 'No service for type Microsoft.AspNetCore.Identity.RoleManager'1[Microsoft.AspNetCore.Identity.IdentityRole] has been registered. EDIT*** I think the issue is that the code...
OCTAVIAN
0

votes
1

answer
12

Views

How to get hyperlink in a formula using EPPlus

I need to get the exact link inside the formula(HYPERLINK) and save it to the database. here is my code to get the link, answerList.Add(new SurveyCompetitorAnswer { MainSurveyId = id, Answer = workSheet.Cells[AnswerRowRange].Text, DateCreated = DateTime.Now, Link = workSheet.Cells[AnswerRowRange].F...
Chris May
1

votes
1

answer
95

Views

.net core web api app with https in docker

I have the simplest possible Web Api app in .net core ( with the default api/values api you get upon creation) I've enabled HTTPS so in debug it works, and kestrel reports: Hosting environment: Development Now listening on: https://localhost:5001 Now listening on: http://localhost:5000 When I run...
Greg Balajewicz
1

votes
2

answer
190

Views

How to customize error response in web api with .net core?

I am using .net core 2.2 with web api. I have created one class i.e. as below : public class NotificationRequestModel { [Required] public string DeviceId { get; set; } [Required] public string FirebaseToken { get; set; } [Required] public string OS { get; set; } public int StoreId { get; set; } } U...
Srusti Thakkar
1

votes
1

answer
92

Views

Net Core MVC: Name Session does not exist in Current Context

I am receiving an error in the last line. How would I resolve this? Trying to convert Net 4.6.2 Project to MVC Net Core. Last Line Error: Name Session does not exist in Current Context. public class TransferPropertyOwnershipController : Controller { public ActionResult GetNewOwnerRecord(int ownerID...
John Thomas
1

votes
1

answer
29

Views

How to run .net unit tests in Docker without installing the whole SDK? [closed]

Is there a way to run .net unit tests (xunit or others) in Docker without installing the whole SDK? I would like to have a minimal Docker image that would be use exclusively to run my tests.
Stephane Simard
1

votes
2

answer
58

Views

Why does OAuth fail when using ASP.NET Identity Core?

I have an ASP.NET Core 2.x project with the following configuration: services .AddAuthentication(options => options.DefaultScheme = CookieAuthenticaitonDefaults.AuthenticationScheme) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme) .AddFacebook(ConfigureFacebook); Predictably, when I ca...
Jesse Hallam
1

votes
1

answer
65

Views

ASP.NET Core DI with Simple Injector sharing DbContext

I'm setting up an ASP.NET Core project and following a CQRS pattern basing my work on the Tripod project. I've followed the Simple Injector integration guide but a little puzzled on one point... I want to keep make use of the UseInMemoryDatabase option for testing and can only find examples of that...
Stephen York
1

votes
1

answer
43

Views

Unable to resolve dependency for generic repository using autofac

I am working with .net core API and resolving my dependency using autofac. However somehow I am not able to resolve dependency for my Generic Repository. Can someone guide what I have done wrong. startup.cs var builder = new ContainerBuilder(); builder.RegisterType().As() .InstancePerLifetimeScope...
Kaushik Thanki
1

votes
1

answer
26

Views

How do I get CreatedAtAction to add a query parameter?

Is there a way to have CreatedAtAction append a query parameter to the Location header that gets generated? The action method I'm using is declared as such: [HttpGet('{candidateId:guid}')] public async Task Get(Guid candidateId, [FromQuery][Required]string siteId) and I'm pointing to it when calling...
s.m.
1

votes
4

answer
103

Views

RESTful API endpoint naming

I'm working on a asp.net core 2.2 backend exposing a RESTful API. The current implementation works fine (additional code removed for clarity): namespace Sppd.TeamTuner.Controllers { [Authorize] [ApiController] [Route('[controller]')] public class UsersController : ControllerBase { private readonly I...
Philippe
1

votes
1

answer
133

Views

Microsoft.Extensions.EntityFrameworkCore namespace not found in .NET Core 2.2

I'm reading the book 'Pro ASP.NET Core MVC 2' and following his samples, and have reached the point where he introduces EF Core. He says to add the following to the .csproj file... ...and then add the following to the ConfigureServices method in Startup.cs... services.AddDbContext(options => options...
Avrohom Yisroel
1

votes
2

answer
41

Views

Change default timezone in ASP.NET Core 2.2 on Docker for 24h time format

I want to use German date formatting as default for my ASP.NET Core 2.2 application. On my Win10 machine with German language/layout it works, so I assumed that the timezone has to be set in my Dockerfile. According to the Alpine wiki, I did this: FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine3....
Lion
1

votes
1

answer
32

Views

Move DbSet<TEntity> properties to a Separate Class in Entity Framework Core

Here is what I have currently in MyContext class public class MyContext:DbContext { public DbSet Countries { get; set; } public DbSet States { get; set; } } What I want is to place all these DbSet properties into a separate file and just have one statement on MyContext class to add all...
Bipn Paul
1

votes
1

answer
51

Views

How we can implement a “Bell Notification” inside asp.net mvc-6 core

I am working on an asp.net core web application, and our system has a lot of functionality to assign items to registered users where i want to notify the users about these items, by implementing a Bell-like notification (which is been used by a lot of social media site), as follow:- now at this stag...
test test

View additional questions