Questions tagged [asp.net-core]
ASP.NET Core is an open-source, cross-platform framework for building web applications. Use this tag for questions about ASP.NET Core applications. Use a specific version tag when your question is specific to a particular version of ASP.NET Core.
asp.net-core
8,256
questions
659
votes
18
answers
557k
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 possible to override bool AuthorizeCore(HttpContextBase httpContext). But this no longer exists in ...
340
votes
9
answers
495k
views
Returning a file to View/Download in ASP.NET MVC
I'm encountering a problem sending files stored in a database back to the user in ASP.NET MVC. What I want is a view listing two links, one to view the file and let the mimetype sent to the browser ...
2116
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 ...
589
votes
42
answers
443k
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 : IService { }
public class ServiceB : IService { }
public class ServiceC : IService { }
...
133
votes
15
answers
197k
views
Increase upload file size in Asp.Net core
Currently, I am working with Asp.Net Core and MVC6 need to upload file size unlimited. I have searched its solution but still not getting the actual answer.
I have tried this link
If anyone have any ...
235
votes
7
answers
352k
views
Select Tag Helper in ASP.NET Core MVC
I need some help with the select tag helper in ASP.NET Core.
I have a list of employees that I'm trying to bind to a select tag helper. My employees are in a List<Employee> EmployeesList and ...
331
votes
26
answers
434k
views
How to enable CORS in ASP.NET Core
I am trying to enable cross origin resources sharing on my ASP.NET Core Web API, but I am stuck.
The EnableCors attribute accepts policyName of type string as parameter:
// Summary:
// Creates a ...
335
votes
38
answers
536k
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 (Add default security headers in .Net Core).
I also have a Client Website which I want to make consume that ...
522
votes
25
answers
1.0m
views
Dependency Injection error: Unable to resolve service for type while attempting to activate, while class is registered
I created an .NET Core MVC application and use Dependency Injection and Repository Pattern to inject a repository to my controller. However, I am getting an error:
InvalidOperationException: Unable ...
451
votes
29
answers
897k
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 ...
202
votes
7
answers
155k
views
Where did IMvcBuilder AddJsonOptions go in .Net Core 3.0?
I've just upgraded my ASP web API project from .NET Core 2.0 to 3.0. I was using
services.AddMvc()
.AddJsonOptions(opts => opts.SerializerSettings.ContractResolver
= new ...
175
votes
7
answers
109k
views
Access the current HttpContext in ASP.NET Core
I need to access current HttpContext in a static method or a utility service.
With classic ASP.NET MVC and System.Web, I would just use HttpContext.Current to access the context statically. But how ...
112
votes
20
answers
260k
views
How to run stored procedures in Entity Framework Core?
I am using EF Core 1.0 in an ASP.NET Core App. Can you please point me to the proper way of executing stored procedures? The old method with ObjectParameters and ((IObjectContextAdapter)this)....
218
votes
17
answers
219k
views
Publish to IIS, setting Environment Variable
Reading these two questions/answers I was able to run an Asp.net 5 app on IIS 8.5 server.
Asp.net vNext early beta publish to IIS in windows server
How to configure an MVC6 app to work on IIS?
The ...
307
votes
3
answers
470k
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 ...