Tag: asp.net

47 votes
12 answers
3K views
ASP.NET Core form POST results in a HTTP 415 Unsupported Media Type response

Sending a form POST HTTP request (Content-Type: application/x-www-form-urlencoded) to the below controller res

avatar
Daniel
0 1 0 9
asked 07 September, 2021
66 votes
9 answers
2K views
How to return HTTP 500 from ASP.NET Core RC2 Web Api?

Back in RC1, I would do this: [HttpPost] public IActionResult Post([FromBody]string something) { try{

avatar
Roger
0 1 0 9
asked 07 September, 2021
64 votes
30 answers
2.3K views
How to enable CORS in ASP.net Core WebAPI

What I am trying to do I have a backend ASP.Net Core Web API hosted on an Azure Free Plan (Source Code: https

avatar
Corey
0 1 0 9
asked 07 September, 2021
55 votes
17 answers
2.8K views
How do I get client IP address in ASP.NET CORE?

Can you please let me know how to get client IP address in ASP.NET when using MVC 6. Request.ServerVariables["

avatar
Majorie
0 1 0 9
asked 07 September, 2021
52 votes
18 answers
2.8K 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 Co

avatar
Scot
0 1 0 9
asked 07 September, 2021
56 votes
12 answers
1.9K views
How to specify the port an ASP.NET Core application is hosted on?

When using WebHostBuilder in a Main entry-point, how can I specify the port it binds to? By default it uses 50

avatar
Suzan
0 1 0 9
asked 07 September, 2021
52 votes
14 answers
1.6K views
Command dotnet ef not found in .NET Core 3

I'm following the docs in order to create an initial migration. When I execute dotnet, I get the help sec

avatar
Rudolf
0 1 0 9
asked 07 September, 2021
61 votes
23 answers
2.9K views
ASP.NET Core Dependency Injection error: Unable to resolve service for type while attempting to activate

I created an .NET Core MVC application and use Dependency Injection and Repository Pattern to inject a reposit

avatar
Trudy
0 1 0 9
asked 07 September, 2021
57 votes
17 answers
2.6K views
How to set up Automapper in ASP.NET Core

I'm relatively new at .NET, and I decided to tackle .NET Core instead of learning the "old ways". I found

avatar
Corey
0 1 0 9
asked 07 September, 2021
54 votes
23 answers
1.3K 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": { "t

avatar
Benton
0 1 0 9
asked 07 September, 2021
58 votes
12 answers
2.3K views
ASP.NET Core Web API exception handling

I am using ASP.NET Core for my new REST API project after using regular ASP.NET Web API for many years. I don&

avatar
Clarice
0 1 0 9
asked 07 September, 2021
62 votes
18 answers
2.3K 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

avatar
Leonardo
0 1 0 9
asked 07 September, 2021
63 votes
30 answers
2.1K views
How to register multiple implementations of the same interface in Asp.Net Core?

I have services that are derived from the same interface. public interface IService { } public class ServiceA

avatar
Kurtis
0 1 0 9
asked 07 September, 2021
56 votes
20 answers
2.3K views
Visual Studio 2017 error: Unable to start program, An operation is not legal in the current state

After fresh installation of Visual Studio 2017 I tried to run .NET Core Web project and when trying to run it

avatar
Wilber
0 1 0 9
asked 07 September, 2021
59 votes
8 answers
1.3K views
Resolving instances with ASP.NET Core DI from within ConfigureServices

How do I manually resolve a type using the ASP.NET Core MVC built-in dependency injection framework? Setting

avatar
Shanita
0 1 0 9
asked 07 September, 2021
60 votes
15 answers
2.8K views
How do you create a custom AuthorizeAttribute in ASP.NET Core?

I'm trying to make a custom authorization attribute in ASP.NET Core. In previous versions it was possibl

avatar
Louetta
0 1 0 9
asked 07 September, 2021
58 votes
8 answers
2.7K 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

avatar
Vi
0 1 0 9
asked 07 September, 2021
54 votes
13 answers
2.8K views
.NET Configuration (app.config/web.config/settings.settings)

I have a .NET application which has different configuration files for Debug and Release builds. E.g. the debug

avatar
Fabian
0 1 0 9
asked 07 September, 2021
54 votes
15 answers
377 views
Best way in asp.net to force https for an entire site?

About 6 months ago I rolled out a site where every request needed to be over https. The only way at the time

avatar
Forrest
0 1 0 9
asked 07 September, 2021
64 votes
11 answers
1.6K views
ASP.NET MVC controller actions that return JSON or partial html

I am trying to create controller actions which will return either JSON or partial html depending upon a parame

avatar
Brianne
0 1 0 9
asked 07 September, 2021