All Questions

Tagged with
Filter by
Sorted by
Tagged with
144 votes
5 answers
68k views

How to consume a Scoped service from a Singleton?

How should I inject (using .NET Core's built-in dependency injection library, MS.DI) a DbContext instance into a Singleton? In my specific case the singleton is an IHostedService? What have I tried I ...
Shoe's user avatar
  • 75.6k
136 votes
5 answers
83k views

Why does aspnet core start on port 80 from within Docker?

TL;DR: Why does an aspnet core app run on port 80 from within a Docker image, but 5000 outside a docker image. Elaborate I went through the aspnet core / docker tutorial found here: https://learn....
Phillip Scott Givens's user avatar
134 votes
3 answers
64k views

I'm lost. What happened to ASP.NET MVC 5?

I've been keeping my head down working on various projects and apparently Microsoft has been busy making some big changes and it's confusing the hell out of me. ASP.NET Core first came onto my radar ...
xr280xr's user avatar
  • 12.9k
115 votes
12 answers
97k views

Return View as String in .NET Core

I found some article how to return view to string in ASP.NET, but could not covert any to be able to run it with .NET Core public static string RenderViewToString(this Controller controller, string ...
Hasan A Yousef's user avatar
81 votes
7 answers
45k views

What's the difference between ASP.NET 5, .NET Core, and ASP.NET Core 5? [closed]

I'm confused on the distinction between these terms: ASP.NET 5 (now renamed ASP.NET Core and released as 1.0, not 5.0) ASP.NET Core 5 .NET Core Can anyone briefly explain it?
ijaz's user avatar
  • 1,150
78 votes
3 answers
100k views

How to extract custom header value?

I have this exact code from the accepted answer in my project which I need to migrate into ASP.NET Core MVP. How to extract custom header value in Web API message handler? var env = Request.Headers....
Kemal Tezer Dilsiz's user avatar
75 votes
32 answers
105k views

Unable to start process dotnet.exe

I am attempting to setup a new work space and transfer all of my projects from my old computer to the new one. However, I am getting this error when I try to run IIS Express: Unable to start ...
marino-mcgalla's user avatar
68 votes
1 answer
36k views

Which web server are you using in production for ASP.NET Core on a *nix server?

With ASP.NET Core now released, I was wondering what the best hosting option is for Linux and Mac environments. Is there any production grade web server under active development? The only one I'm ...
reggaemahn's user avatar
  • 6,420
64 votes
9 answers
108k views

Receive file and other form data together in ASP.NET Core Web API (boundary based request parsing)

How would you form your parameters for the action method which is supposed to receive one file and one text value from the request? I tried this public string Post([FromBody]string name, [FromBody]...
shashwat's user avatar
  • 7,915
60 votes
5 answers
128k views

How to get absolute path in ASP.Net Core alternative way for Server.MapPath

How to get absolute path in ASP net core alternative way for Server.MapPath I have tried to use IHostingEnvironment but it doesn't give proper result. IHostingEnvironment env = new ...
Shanmu_92's user avatar
  • 835
58 votes
9 answers
52k views

ASPNETCORE_ENVIRONMENT in Docker

i have problems setting the ASPNETCORE_ENVIRONMENT variable running my project in a docker container. The problem is that the value is always set/overwritten to "Development". I have tried ...
Aaron's user avatar
  • 619
55 votes
7 answers
58k views

The constraint reference 'string' could not be resolved to a type. (netcoreapp3.0)

I have got an error. This is my Startup class. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); } public void Configure(IApplicationBuilder app) { app....
Uğur Canbulat's user avatar
54 votes
4 answers
102k views

The current .NET SDK does not support targeting .NET Core 3.0 | 3.1 | 5.0 | 6.0

I've just downloaded the release version of .NET Core 3.0.100 It was installed alongside older version that I have: When I try to run dotnet restore for a project that targets .NET Core 3 (<...
user10962730's user avatar
  • 1,009
49 votes
2 answers
49k views

Where's the NuGet package location in ASP.NET Core?

I'm new to ASP.NET Core, and am trying to figure out where NuGet packages are stored on my local machine. I've installed the following NuGet packages: nuget dapper nuget MicroOrm.Pocos.SqlGenerator ...
nam vo's user avatar
  • 3,377
48 votes
3 answers
32k views

What is the difference between UseHttpsRedirection and UseHsts

I don't quite get the difference between UseHsts and UseHttpsRedirection in the configure section of the startup file in .net core. Could anyone explain?
Roger Lebrun's user avatar
44 votes
4 answers
33k views

ASP.NET 5 (vNext) - Getting a Configuration Setting

I'm writing a basic app to learn ASP.NET 5. One area I find very confusing is configuration. Prior to ASP.NET 5, I could do the following: var settingValue = ConfigurationManager.AppSettings["SomeKey"...
xam developer's user avatar
43 votes
2 answers
125k views

How to set default page asp.net [duplicate]

I've just published my site in my server, but when I type in the browser www.mysite.com I get this error : HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of ...
Norman's user avatar
  • 453
43 votes
2 answers
24k views

What is the use of Normalized Email & UserName in .NET core IdentityUser Model?

When I use IdentityUser model in Asp.Net Identity with EntityFramework, it creates some standard fields in the database. All the fields are self explanatory except for the below two fields. ...
Faraj Farook's user avatar
  • 14.7k
42 votes
3 answers
25k views

How can I list all of the configuration sources or properties in ASP.NET Core?

I want to ensure that a particular configuration property is being read from a configuration source. I was going to print out all of the configuration sources (or print out all of the configuration ...
Ben Klein's user avatar
  • 1,819
42 votes
9 answers
57k views

Error "dotnet : Could not find any project in `C:\**." when running "dotnet add package Microsoft.AspNetCore.Authentication.MicrosoftAccount"

I have visual studio 2019 and i created a new asp.net core 2.2 project. now i am following these steps Configure Microsoft Account Authentication to enable external login to our web application. but ...
John John's user avatar
40 votes
3 answers
25k views

Can I use Entity Framework 6 (not core) in .net core?

Entity Framework Core does not support spatial data, which I need to use in my app. Can I use Entity Framework 6 in .net core? If so, how can I register DatabaseContext in Startup.cs?
kostik's user avatar
  • 669
39 votes
4 answers
37k views

How to force Visual Studio to re-create the SSL certificate for a .NET Core Web Application running Kestrel?

When a web project is created, Visual Studio automatically generates a SSL certificate and prompts you to install it. Everything works fine. That certificate has now expired and I cannot figure out ...
automaton's user avatar
  • 2,490
38 votes
4 answers
16k views

Login with ASP Identity fails every time with "Not Allowed" (even when 'email' and 'username' have the same value))

Registering a user works fine, as it logs in via this line: await _signInManager.SignInAsync(user, isPersistent: model.RememberMe); But if I want to log in with the same user again does not work (...
user avatar
36 votes
3 answers
30k views

ASP.NET Core Singleton instance vs Transient instance performance

In ASP.NET Core Dependency Injection, I just wonder if registering Singleton instances will improve performance instead of registering Transient instances or not? In my thinking, for Singleton ...
tuq's user avatar
  • 1,448
35 votes
8 answers
32k views

Cannot install dotnet-ef tool on Windows 10

I'm trying to install the dotnet-ef tool via the dotnet-cli. The command that I enter: dotnet tool install --global dotnet-ef I gives me the following error: The tool package could not be restored. ...
sdfsd's user avatar
  • 1,163
35 votes
7 answers
23k views

GZIP in .net core not working

I'm attempting to add Gzip middleware to my ASP.net core app. I have added the following package : "Microsoft.AspNetCore.ResponseCompression": "1.0.0" In my startup.cs for the Configure ...
MindingData's user avatar
  • 12.2k
33 votes
2 answers
16k views

How to disable Chunked Transfer Encoding in ASP.Net C# using HttpClient

I'm trying to post some JSON to an external API which keeps failing because my content is chunked. Please can someone tell me how to disable it? I'm using ASP.NET 5 so think I'm using System.Net.Http,...
dontbesorry80's user avatar
32 votes
1 answer
11k views

Differences between ASP.NET Web Application (.NET Framework) vs ASP.NET Core Web Application (.NET Framework)

Why should I choose ASP.NET Web Application (.NET Framework) instead of ASP.NET Core Web Application (.NET Framework)? I'm talking about options 1 and 3 in the options below, what will be the ...
Tomer Peled's user avatar
  • 3,591
31 votes
2 answers
17k views

AutoValidateAntiForgeryToken vs. ValidateAntiForgeryToken

I was trying to secure a post method against side scripting just now through providing an anti forgery token but noticed, in .Net Core there is another attribute named as AutoAntiForgeryToken. The XML ...
Arnold Zahrneinder's user avatar
30 votes
5 answers
19k views

Dotnet core 2.0 authentication multiple schemas identity cookies and jwt

In dotnet core 1.1 asp, I was able to configure and use identity middleware followed by jwt middleware by doing the following: app.UseIdentity(); app.UseJwtBearerAuthentication(new ...
didiHamman's user avatar
30 votes
2 answers
4k views

What is the difference between creating a project ASP.NET Core (.NET Core) and ASP.NET Core (.NET Framework)

I don't see clearly the main difference between the last two project types, actually which sense have the last one? .NET Core and .NET Framework?
Israel Garcia's user avatar
29 votes
4 answers
58k views

How to find ASP.Net Core version?

I'm using WebsitePanel and in Web Sites ==> Extensions tab, the ASP.NET version is 4 integrated pipeline. My question is that how can I figure out what version of .Net Core is my server using now? ...
Saeed's user avatar
  • 3,717
29 votes
5 answers
52k views

Keycloak client for ASP.NET Core

Is there any existing Keycloak client for Asp.net Core? I have found a NuGet package for .net but it doesn't work with Core. Do you have any ideas how to easily integrate with this security server (or ...
Michał J. Gąsior's user avatar
29 votes
8 answers
31k views

How to automatically reload .NET Core project in Visual Studio 2019

I tried to automatically reload ASP.NET Core project as I do using Angular with Node or NPM. When I change the code of the .NET Core project and save, I want the web page to be automatically refreshed ...
Akash Limbani's user avatar
28 votes
3 answers
20k views

.net Core on Windows vs Linux

ASP.Net Core runs on both Windows and Linux Docker containers. Considering Linux hosts are cheaper than Windows hosts, what is the benefit of running your app on IIS/Windows vs Nginx/Linux if one ...
Piersdb's user avatar
  • 435
27 votes
3 answers
42k views

How to write custom actionResult in asp.net core

In webApi2 i could write a custom ActionResult by inheriting IHttpActionResult. Sample : public class MenivaActionResult : IHttpActionResult { private readonly HttpRequestMessage ...
Binson Eldhose's user avatar
26 votes
8 answers
46k views

How to remove previous versions of .NET Core from Linux (CentOS 7.1)

I would like to install the current version Core 1.0. Currently the RC2 version is installed. The instruction on the official website are: Before you start, please remove any previous versions of ....
stevo's user avatar
  • 2,244
26 votes
6 answers
12k views

Get HTTP status code descriptions in ASP.Net Core

In previous versions of ASP.Net, we could retrieve the description of a HTTP status code in a few ways as shown here: Get description for HTTP status code Is there something similar to ...
Mister Epic's user avatar
  • 16.5k
26 votes
7 answers
18k views

The referenced project is a non self-contained executable. A non self-contained executable cannot be referenced by a self-contained executable

I'm having an issue regarding trying to compile my .netcore3.1 after updated the SDK to .NET 6.0 preview while debugging through Visual Studio. My CSProject is bellow : <Project Sdk="Microsoft....
ariefs's user avatar
  • 689
26 votes
2 answers
10k views

Visual Studio 2015 Web Application .NET Core vs .NET Framework

In Visual Studio Enterprise 2015 (v14.0.25123.00 Update 2) when I go to: Start > New Project With Target Framework 4.5 or higher selected... Under: Installed | |--> Visual C# | ...
Fernando Vega's user avatar
25 votes
5 answers
17k views

HTTP Error 500.19 with Error Code 0x8007000d visual studio 2017 while deploying .net core application

I created default .net core application using visual studio 2017 and am trying to publish it, The application works perfectly when I start it with visual studio 2017, IIS Express. But when I publish ...
Badri Neparidze's user avatar
25 votes
2 answers
5k views

How to configure multiple ASPNETCORE_ENVIRONMENT on same machine?

I have ASP.NET core web application. I have configured the web application on our web server and set the ASPNETCORE_ENVIRONMENT variable to Development. I set this variable at machine level like shown ...
LP13's user avatar
  • 32.3k
24 votes
2 answers
23k views

WindowsImpersonationContext & Impersonate() not found in ASP.Core

I had the following in a .NET Framework 4.0 assembly: var newId = new WindowsIdentity(duplicateTokenHandle); WindowsImpersonationContext newId = ImpersonatedIdentity.Impersonate(); I'm porting it to ...
BanksySan's user avatar
  • 28k
24 votes
2 answers
26k views

SMTP settings in appSettings.json in dotnet core 2.0

In Asp.net, I can normally send emails using the following code: using (var smtp = new SmtpClient()) { await smtp.SendMailAsync(mailMessage); } With the smtp settings being provided in the web....
ViqMontana's user avatar
  • 5,273
23 votes
6 answers
51k views

Model bound complex types must not be abstract or value types and must have a parameterless constructor

I have the following problem, I created an application to add game categories and the games themselves to the database. I created a relationship and unfortunately when I add to the database I get an ...
PawelC's user avatar
  • 1,176
22 votes
2 answers
17k views

How do I (gracefully) shut down a worker service from within itself?

I'm using the .NET Core 3.1 worker service template to build a Windows Service. I gather that the basic flow should be handled within ExecuteAsync, roughly like so: protected override async ...
Sören Kuklau's user avatar
22 votes
6 answers
34k views

Could not find 'aspnetcorev2_inprocess.dll'. Exception message

I'm trying to publish an asp.net core v3 app to run under IIS. I created a virtual directory, converted to application. It has it's own IIS app pool that is setup with CLR: No Managed Code, 32 bit:...
Scott Wylie's user avatar
21 votes
1 answer
22k views

Net Core 2.0 looking for appsettings.Production.json

I have created a couple of these .net core 2 web app and no issue until this one. Running local under IISExpress it runs correctly but when I deploy a debug version to an IIS folder on the server I ...
Gina Marano's user avatar
  • 1,793
21 votes
2 answers
21k views

How can VS Code be configured to run and debug with IIS Express and ASP.NET core?

I have been able to run ASP.NET core applications with Visual Studio 2017. Visual Studio has the integration of IIS Express and ASP.NET core all setup and it works with F5. I would like to get this ...
Matthew MacFarland's user avatar
20 votes
4 answers
28k views

Ninject in .NET Core

I am trying to install Ninject 3.3.2 in .NET Core, Released in May 2016. I got an error: The dependency Ninject 3.2.2 does not support framework .NETCoreApp, Version=v1.0. Does anybody had similar ...
Dejan Dimčić's user avatar

1
2 3 4 5
38