All Questions
Tagged with .net-core asp.net-core 
            
            8,896
            questions
        
        
            2093
            votes
        
        
            14
            answers
        
        
            1.5m
            views
        
    AddTransient, AddScoped and AddSingleton Services Differences
                I want to implement dependency injection (DI) in ASP.NET Core. So after adding this code to ConfigureServices method, both ways work.
What is the difference between the services.AddTransient and ...
            
        
       
    
            522
            votes
        
        
            16
            answers
        
        
            379k
            views
        
    Command dotnet ef not found
                I'm following the docs in order to create an initial migration. When I execute dotnet, I get the help section, meaning that the PATH works properly.
Then I try to execute the command below from the ...
            
        
       
    
            458
            votes
        
        
            20
            answers
        
        
            571k
            views
        
    How to unapply a migration in ASP.NET Core with EF Core
                When I run PM> Remove-Migration -context BloggingContext in VS2015 with an ASP.NET Core project using EF Core, I get the following error:
System.InvalidOperationException: The migration '...
            
        
       
    
            448
            votes
        
        
            29
            answers
        
        
            879k
            views
        
    How to read AppSettings values from a .json file in ASP.NET Core
                I have set up my AppSettings data in file appsettings/Config .json like this:
{
  "AppSettings": {
        "token": "1234"
    }
}
I have searched online on how to read AppSettings values from .json ...
            
        
       
    
            428
            votes
        
        
            21
            answers
        
        
            529k
            views
        
    How to determine if .NET Core is installed
                I know that for older versions of .NET, you can determine if a given version is installed by following 
https://support.microsoft.com/en-us/kb/318785  
Is there an official method of determining if ....
            
        
       
    
            305
            votes
        
        
            3
            answers
        
        
            463k
            views
        
    How to get HttpContext.Current in ASP.NET Core? [duplicate]
                We are currently rewriting/converting our ASP.NET WebForms application using ASP.NET Core. Trying to avoid re-engineering as much as possible.
There is a section where we use HttpContext in a class ...
            
        
       
    
            299
            votes
        
        
            5
            answers
        
        
            184k
            views
        
    .NET Core vs ASP.NET Core
                What exactly is the difference between .NET Core and ASP.NET Core?
Are they mutually exclusive? I heard ASP.NET Core is built on .NET Core, but it can also be built on the full .NET framework.
So ...
            
        
       
    
            283
            votes
        
        
            15
            answers
        
        
            483k
            views
        
    How to read values from the querystring with ASP.NET Core?
                I'm building one RESTful API using ASP.NET Core MVC and I want to use querystring parameters to specify filtering and paging on a resource that returns a collection.
In that case, I need to read the ...
            
        
       
    
            275
            votes
        
        
            11
            answers
        
        
            217k
            views
        
    Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing
                I had an Asp.Net core 2.2 project. 
Recently, I changed the version from .net core 2.2 to .net core 3.0 Preview 8. After this change I see this warning message: 
  using 'UseMvc' to configure MVC is ...
            
        
       
    
            269
            votes
        
        
            4
            answers
        
        
            246k
            views
        
    .NET Core DI, ways of passing parameters to constructor
                Having the following service constructor
public class Service : IService
{
     public Service(IOtherService service1, IAnotherOne service2, string arg)
     {    
     }
}
What are the choices of ...
            
        
       
    
            252
            votes
        
        
            29
            answers
        
        
            211k
            views
        
    Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found
                I am working on a fabric application where I have configured HTTPS. It is throwing an exception though I have a valid installed certificate.
            
        
       
    
            240
            votes
        
        
            18
            answers
        
        
            124k
            views
        
    .NET Core MVC Page Not Refreshing After Changes
                I'm building a .NET Core MVC on the latest version 2.2. I have a problem when I make changes to the CSHTML file and refresh the page, my changes are not reflected in the browser. I have to restart the ...
            
        
       
    
            238
            votes
        
        
            14
            answers
        
        
            381k
            views
        
    Automatically set appsettings.json for dev and release environments in asp.net core?
                I've defined some values in my appsettings.json for things like database connection strings, webapi locations and the like which are different for development, staging and live environments.
Is there ...
            
        
       
    
            229
            votes
        
        
            6
            answers
        
        
            347k
            views
        
    Return file in ASP.Net Core Web API
                Problem
I want to return a file in my ASP.Net Web API Controller, but all my approaches return the HttpResponseMessage as JSON.
Code so far
public async Task<HttpResponseMessage> ...
            
        
       
    
            205
            votes
        
        
            5
            answers
        
        
            145k
            views
        
    How to SetBasePath in ConfigurationBuilder in Core 2.0
                How can I set the base path in ConfigurationBuilder in Core 2.0. 
I have googled and found this question, this from Microsoft docs, and the 2.0 docs online but they seem to be using a version of ...
            
        
       
    
            185
            votes
        
        
            6
            answers
        
        
            248k
            views
        
    Send HTTP POST message in ASP.NET Core using HttpClient PostAsJsonAsync
                I want to send dynamic object like
new { x = 1, y = 2 };
as body of HTTP POST message. So I try to write
var client = new HttpClient();
but I can't find method 
client.PostAsJsonAsync()
So I ...
            
        
       
    
            184
            votes
        
        
            7
            answers
        
        
            215k
            views
        
    The default XML namespace of the project must be the MSBuild XML namespace
                I cloned the ASP.NET Core SignalR Repo locally, and try opening the solution from within the following environment.
IDE
Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
...
            
        
       
    
            178
            votes
        
        
            11
            answers
        
        
            202k
            views
        
    How to log to a file without using third party logger in .Net Core?
                How to log to a file without using third party logger (serilog, elmah etc.) in .NET CORE?
public void ConfigureServices(IServiceCollection services)
{
    services.AddLogging();
}
public void ...
            
        
       
    
            161
            votes
        
        
            15
            answers
        
        
            238k
            views
        
    How to use appsettings.json in Asp.net core 6 Program.cs file
                I'm trying to access appsettings.json in my Asp.net core v6 application Program.cs file, but in this version of .Net the Startup class and Program class are merged together and the using and another ...
            
        
       
    
            148
            votes
        
        
            12
            answers
        
        
            184k
            views
        
    Setting the version number for .NET Core projects - CSPROJ - not JSON projects
                This question is very similar to Setting the version number for .NET Core projects, but not the same. Using the latest stable version of .NET Core at the time of writing (1.1) and VS2017, .NET Core ...
            
        
       
    
            144
            votes
        
        
            17
            answers
        
        
            229k
            views
        
    Entity Framework Core: `SqlNullValueException: Data is Null.` How to troubleshoot?
                I am using Entity Framework Core in an ASP.NET Core application and Controller action and I haven't changed something to the working code nor to the database but I can't tell what is the query ...
            
        
       
    
            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 ...
            
        
       
    
            139
            votes
        
        
            6
            answers
        
        
            128k
            views
        
    How to extract a list from appsettings.json in .net core
                I have an appsettings.json file which looks like this:
{
    "someSetting": {
        "subSettings": [
            "one",
            "two",
            "three"
         ]
    }
}
When I build my ...
            
        
       
    
            132
            votes
        
        
            11
            answers
        
        
            117k
            views
        
    Upload files and JSON in ASP.NET Core Web API
                How can I upload a list of files (images) and json data to ASP.NET Core Web API controller using multipart upload?
I can successfully receive a list of files, uploaded with multipart/form-data ...
            
        
       
    
            128
            votes
        
        
            26
            answers
        
        
            296k
            views
        
    How to change the port number for Asp.Net core app?
                I added the following section in project.json.
  "commands": {
    "run": "run server.urls=http://localhost:8082",
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --...
            
        
       
    
            126
            votes
        
        
            7
            answers
        
        
            133k
            views
        
    Switch between dotnet core SDK versions
                I recently installed VS 2017 RC and then automatically my dotnet version pointed to 1.0.0-preview4-004233. Due to that whenever I create a new project using command dotnet new -t Console I cannot see ...
            
        
       
    
            126
            votes
        
        
            4
            answers
        
        
            104k
            views
        
    .NET Core IServiceScopeFactory.CreateScope() vs IServiceProvider.CreateScope() extension
                My understanding is that when using the built in the dependency injection, a .NET Core console app will require you to create and manage all scopes yourself whereas a ASP.NET Core app will create and ...
            
        
       
    
            125
            votes
        
        
            14
            answers
        
        
            122k
            views
        
    How to load appsetting.json section into Dictionary in .NET Core?
                I am familiar with loading an appsettings.json section into a strongly typed object in .NET Core Startup.cs. For example:
public class CustomSection 
{
   public int A {get;set;}
   public int B {get;...
            
        
       
    
            123
            votes
        
        
            3
            answers
        
        
            73k
            views
        
    'ConfigurationBuilder' does not contain a definition for 'AddJsonFile'
                I have the following error:
Program.cs(15,72): error CS1061: 'ConfigurationBuilder' does not contain a definition for 'AddJsonFile' and no accessible extension method 'AddJsonFile' accepting a first ...
            
        
       
    
            122
            votes
        
        
            6
            answers
        
        
            168k
            views
        
    How to set json serializer settings in asp.net core 3?
                json serializer settings for legacy asp.net core applications were set by adding AddMvc().AddJsonOptions(), but I don't use AddMvc() in asp.net core 3. So how can I set global json serialization ...
            
        
       
    
            121
            votes
        
        
            3
            answers
        
        
            175k
            views
        
    How to use SqlClient in ASP.NET Core?
                I am trying to use SQLClient library in the ASP.net Core but cant seem to get it working.  I found this article online advising how to setup but its not working for me: http://blog.developers.ba/using-...
            
        
       
    
            121
            votes
        
        
            2
            answers
        
        
            20k
            views
        
    On IServiceProvider what are the differences between the GetRequiredService and GetService methods?
                What are the differences between IServiceProvider.GetRequiredService() and IServiceProvider.GetService()?
When is it a better idea to use GetRequiredService()?
            
        
       
    
            118
            votes
        
        
            4
            answers
        
        
            34k
            views
        
    "The project 'Web' must provide a value for Configuration" error after migrating to .NET Core 3
                I've migrated an ASP.NET Core 2.2 project to Core 3.0 and am getting the error: 
  The project [Project location] must provide a value for Configuration. 
There's not really a lot to go on with that ...
            
        
       
    
            118
            votes
        
        
            6
            answers
        
        
            85k
            views
        
    Dependency Injection with classes other than a Controller class
                At this point I'm injecting things into my Controllers with ease, in some cases building my own ResolverServices class. Life is good.
What I cannot figure out how to do is get the framework to ...
            
        
       
    
            117
            votes
        
        
            39
            answers
        
        
            259k
            views
        
    EF Core add-migration Build Failed
                I have a developer that is getting "Build failed." when running add-migration in a .NET Core EF project, with no explanation of why the build failed. How do you troubleshoot this error?
This is what ...
            
        
       
    
            116
            votes
        
        
            1
            answer
        
        
            45k
            views
        
    .NET Core - When to use "dotnet new sln"
                I'm a bit confused - the majority of .NET Core tutorials I have been reading have not mentioned "dotnet new sln" - they always just create the projects separately without any solution file to link ...
            
        
       
    
            115
            votes
        
        
            14
            answers
        
        
            115k
            views
        
    Cannot find command 'dotnet ef'
                I am using .NET Core 2.0 on Arch Linux / Visual Studio Code and am trying to get EF tools to work, but I keep getting the error:
cannot find command dotnet ef
I've just about looked everywhere and ...
            
        
       
    
            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 ...
            
        
       
    
            115
            votes
        
        
            15
            answers
        
        
            104k
            views
        
    Configuration.GetSection always returns Value property null
                Every time I call Configuration.GetSection, the Value property of the returned object is always null.
My Startup constructor
public Startup(IHostingEnvironment env)
{
    var builder = new ...
            
        
       
    
            112
            votes
        
        
            1
            answer
        
        
            40k
            views
        
    How to override ASP.NET Core configuration array settings using environment variables
                TL;DR
In an ASP.NET Core app, I have an appsettings.json config file which uses a JSON array to configure a collection of settings.
How do I override a setting of one of the array objects using ...
            
        
       
    
            111
            votes
        
        
            7
            answers
        
        
            79k
            views
        
    Populate IConfiguration for unit tests
                .NET Core configuration allows so many options to add values (environment variables, json files, command line args).
I just can't figure out and find an answer how to populate it via code.
I am ...
            
        
       
    
            109
            votes
        
        
            8
            answers
        
        
            99k
            views
        
    No service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]' has been registered
                What is the possible cause of this error:
  InvalidOperationException: No service for type 'Microsoft.AspNetCore.Identity.UserManager [Microsoft.AspNetCore.Identity.IdentityUser]' has been registered....
            
        
       
    
            108
            votes
        
        
            5
            answers
        
        
            148k
            views
        
    Command line to install/upgrade .NET Core
                Are there command line commands to install or upgrade .NET Core?
I checked to see if I had .NET Core was installed on my computer using dotnet --version only to notice that I still had the preview ...
            
        
       
    
            107
            votes
        
        
            5
            answers
        
        
            75k
            views
        
    Replace service registration in ASP.NET Core built-in DI container?
                Let us consider a service registration in Startup.ConfigureServices:
public void ConfigureServices(IServiceCollection services)
{
    services.AddTransient<IFoo, FooA>();
}
Is it possible to ...
            
        
       
    
            106
            votes
        
        
            1
            answer
        
        
            46k
            views
        
    When are .NET Core dependency injected instances disposed?
                ASP.NET Core uses extension methods on IServiceCollection to set up dependency injection, then when a type is needed it uses the appropriate method to create a new instance:
AddTransient<T> - ...
            
        
       
    
            105
            votes
        
        
            4
            answers
        
        
            76k
            views
        
    Net Core API: Purpose of ProducesResponseType
                I want to understand the purpose of ProducesResponseType.
Microsoft defines as:
a filter that specifies the type of the value and status code returned by the action.
So I am curious what are ...
            
        
       
    
            102
            votes
        
        
            6
            answers
        
        
            90k
            views
        
    Unit testing controller methods which return IActionResult
                I'm in the process of building an ASP.NET Core WebAPI and I'm attempting to write unit tests for the controllers.  Most examples I've found are from the older WebAPI/WebAPI2 platforms and don't seem ...
            
        
       
    
            101
            votes
        
        
            17
            answers
        
        
            85k
            views
        
    How to publish environment specific appsettings in .Net core app?
                I have 3 environment specific appsettings files in my .Net core application
in project.json I have setup publishOptions like this. ( based on suggestion here)
"publishOptions": {
    "include": [
   ...
            
        
       
    
            100
            votes
        
        
            7
            answers
        
        
            100k
            views
        
    dotnet run OR dotnet watch with development environment from command line?
                I am using dotnet watch command to run asp.net core project. However, by default, it is picking up the Production as an environment.
I have tried both options using:
1) > dotnet watch ...
            
        
       
    
            100
            votes
        
        
            6
            answers
        
        
            121k
            views
        
    Embedded resource in .Net Core libraries
                I just have started looking into .Net Core, and I don't see classical resources and anything what looks like resources. In classical .Net class libraries I was able to add, for example, text filtes ...