tagged [asp.net-core]

Library NuGet configuration is invalid

Library NuGet configuration is invalid VS2015 Update 3. I created a plain .net core class library. Right-click on Project->References-> Manage Nuget packages throws the following error? What is missin...

access BackgroundService from controller in asp.net core 2.1

access BackgroundService from controller in asp.net core 2.1 I just need to access my from a controller. Since BackgroundServices are injected with How can I use it from a Controller class?

How can I get the current route name with ASP.NET Core?

How can I get the current route name with ASP.NET Core? I have an application that is written on the top of ASP.NET Core 2.2 framework. I have the following controller ``` public class TestController ...

How do you enable cross-origin requests (CORS) in ASP.NET Core MVC

How do you enable cross-origin requests (CORS) in ASP.NET Core MVC I'd like to enable CORS on an API built with ASP.NET Core MVC, but all the current documents refer to earlier versions of that framew...

23 Jan at 08:30

App_Data directory in ASP.NET5 MVC6

App_Data directory in ASP.NET5 MVC6 I've been trying ASP.NET5 MVC6 app. In the previous version, there was a directory . I used this folder to store error logs. But it is not found in latest version. ...

6 Nov at 06:25

WebUtility.HtmlDecode replacement in .NET Core

WebUtility.HtmlDecode replacement in .NET Core I need to decode HTML characters in .NET Core (MVC6). It looks like .NET Core doesn't have WebUtility.HtmlDecode function which everybody used for that p...

28 Feb at 09:18

ServiceFilter and TypeFilter - what is the difference in injection those filters?

ServiceFilter and TypeFilter - what is the difference in injection those filters? ServiceFilter we must register in Startup.cs. TypeFilter is injected by Microsoft.Extensions.DependencyInjection.Objec...

21 Apr at 23:55

How to create a custom Authorize attribute for multiple policies in ASP.NET CORE

How to create a custom Authorize attribute for multiple policies in ASP.NET CORE I want to authorize an action controller could access by multiple policies. .e.g: Thank a lot.

How to add Web API controller to an existing ASP.NET Core MVC?

How to add Web API controller to an existing ASP.NET Core MVC? I created a project using the default ASP.NET Core MVC template. I would like to also create a RESTful API under `/api/{Controller}`. I a...

How to precompile views in ASP.NET Core 2.0?

How to precompile views in ASP.NET Core 2.0? I set up my solution according to this [article](https://dzone.com/articles/self-contained-ui-running-one-aspnet-core-mvc-site). I left out some of the thi...

Manual controller registration in ASP.NET Core dependency injection

Manual controller registration in ASP.NET Core dependency injection I need to override ASP.NET Core's default registration for a certain controller. I've tried the below, but it resolves `MyController...

25 Aug at 15:39

Confused with FromBody in ASP.NET Core

Confused with FromBody in ASP.NET Core I have the following WEB API method, and have a SPA template with Angular: I thought, based on [this](https://stackoverflow.com/questions/24625303/why-do-we-have...

How to unit test ViewComponent.Invoke()?

How to unit test ViewComponent.Invoke()? In `ViewComponent` object, `HttpContext` and `User` are read-only properties. How to unit test such a component? I'm using the MSTest Freamwork. The follow pro...

Should I always add CancellationToken to my controller actions?

Should I always add CancellationToken to my controller actions? Is this a good practice to always add CancellationToken in my actions no matter if operation is long or not? I'm currently adding it to ...

How to get the Development/Staging/production Hosting Environment in ConfigureServices

How to get the Development/Staging/production Hosting Environment in ConfigureServices How do I get the Development/Staging/production Hosting Environment in the `ConfigureServices` method in Startup?...

27 Feb at 10:27

Radio Button Tag Helpers in ASP.NET 5 MVC 6

Radio Button Tag Helpers in ASP.NET 5 MVC 6 I don't see any tag helpers for radio buttons in ASP.NET 5 MVC 6. What's the right way of handling form elements where I need to use radio buttons?

Change the headers of static files in Asp.net Core

Change the headers of static files in Asp.net Core I am using package `Microsoft.AspNet.StaticFiles` and configuring it in `Startup.cs` as `app.UseStaticFiles()`. How can I change the headers of the d...

15 Apr at 10:34

SignalR Core 2.2 CORS AllowAnyOrigin() breaking change

SignalR Core 2.2 CORS AllowAnyOrigin() breaking change To connect via SignalR to an ASP.NET Core 2.1 server from any origin, we had to configure the pipeline as follows: According to [this](https://le...

ASP.NET Core 3.0 [FromBody] string content returns "The JSON value could not be converted to System.String."

ASP.NET Core 3.0 [FromBody] string content returns "The JSON value could not be converted to System.String." Using `[FromBody]` string content on an `ApiController` in ASP.NET Core 3.0 returns a valid...

What is the difference between File(), PhysicalFile(), PhysicalFileResult() in ASP.NET Core?

What is the difference between File(), PhysicalFile(), PhysicalFileResult() in ASP.NET Core? I am trying to build a Web API endpoint using ASP.NET core 3.1 what would allow an application to send me a...

Add a header to all responses in ASP.NET Core MVC

Add a header to all responses in ASP.NET Core MVC I would like to know how I can add `Access-Control-Allow-Origin:*` to my headers. I've tried this unsuccessfully:

How to set json serializer settings in asp.net core 3?

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....

MVC 6 Multiple Get Methods

MVC 6 Multiple Get Methods I am trying to support multiple Get() methods per controller, as well as just specially named methods accessible through web api. I have done this in MVC 5, but can't seem t...

MVC Core IActionResult meaning

MVC Core IActionResult meaning What is an `IActionResult`? I tried looking at MSDN and other sites, but need general, common easy to understand answer. [MSDN IActionResult](https://learn.microsoft.com...

27 Mar at 04:34

No executables found matching command 'dotnet-aspnet-codegenerator'"

No executables found matching command 'dotnet-aspnet-codegenerator'" When trying to add a Controller in an ASP.NET Core project using Visual Studio 15 Enterprise with Update 3, I get the error below: ...