Questions tagged [asp.net-core-5.0]

ASP.NET Core 5 is the current version of ASP.NET Core, built on top of .NET 5. Use this tag for questions specifically about ASP.NET Core 5 and ASP.NET Core 5's formal specification. Do also include the general [asp.net-core] tag.

311 questions
-1
votes
1 answer

DisplayNameFor a Model child collection

Suppose I have class Item { string Name {get; set;} int Type {get; set;} } If I have my model as a collection of Items, the following compiles : @model IEnumerable @Html.DisplayNameFor(model => model.Name) Now supppose I have…
serge
  • 9,891
  • 17
  • 84
  • 142
-1
votes
1 answer

Database column defaults not behaving as expected

I have an issue where writing a new entry to the database isn't using the configured default values as I'd expect. I have some classes: public class Benefits { public string Id { get; set; } [Required, ForeignKey("Id"), JsonIgnore] …
Ouroborus
  • 12,316
  • 1
  • 27
  • 51
-1
votes
1 answer

share the current user in application views

I have a .net core application with a SSO authentication. I need that my controllers and views be aware of the currently authenticated user. I built a service, in witch I obtain the base information from the HttpContext.User.Identity.Name load from…
serge
  • 9,891
  • 17
  • 84
  • 142
-1
votes
1 answer

How to access and replace IServiceCollection in controller

I am working on an web application (.net core 5) and trying to replace a singleton dependency. I know, it is possible to replace dependency inside Startup.cs (ConfigureServices(IServiceCollection services) method) . But problem is I cant access…
Hatef.
  • 490
  • 4
  • 16
-2
votes
1 answer

Getting a conversion error when trying to execute a stored procedue with .NET 5.0 web app

I am writing a .NET 5.0 web app using Entity Framework. I have a SQL Server stored procedure that I need to call to retrieve some data from some complex calculations. I have previously used Microsoft Access to run the stored procedure from and…
-2
votes
1 answer

.net 5.0 Core console application inside windows 2012 R2 will raise error "A fatal error occurred.The required library hostfxr.dll could not be found"

I have developed a .NET 5.0 console application inside Visual Studio 2019 and it is working well. Then I build the project >> move everything inside the "\bin\Debug\net5.0" to a folder inside Windows server 2012 R2 (Our Live Server) >> but when I…
john Gu
  • 10,469
  • 55
  • 189
  • 381
-2
votes
1 answer

Serilog does not take console config from json

I have the following in my asp.net core (5) application: var config = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(config) .CreateLogger(); and…
serge
  • 9,891
  • 17
  • 84
  • 142
-2
votes
1 answer

Select onchange to Controller's Action in .net-core

I have a list of objects classified by type, so I have a "type" select on my view
my controller's…
serge
  • 9,891
  • 17
  • 84
  • 142
-2
votes
2 answers

Web Api: get child entities

I am new to Web Apis (I have an ASP.NET Core Web application with some Apis) Suppose we have Company/Employee and we want to get all employees for a Company via an API. I have Company controller and I would like to return Employees. Suppose we want…
serge
  • 9,891
  • 17
  • 84
  • 142
-2
votes
1 answer

Correctly override the generic BaseController

I have the generic BaseController like this: public class BaseController : Controller where T : BaseEntity { protected readonly IRepository _repository; public BaseController(IRepository repository) { _repository =…
serge
  • 9,891
  • 17
  • 84
  • 142
-3
votes
1 answer

Get an instance of a class by its name

I have StrategyName set in appsettings.json which represents the name of the strategy class. I need to get an instance of it. ITradingStrategy _tradingStrategy = StrategyUtils.GetStrategyInstance(logger, _tradeOptions.StrategyName) which is equal…
nop
  • 1,497
  • 1
  • 3
  • 27
1 2 3
20
21