asp.net-core-mvc

How to change root path ~/ in Razor in asp.net core

故事扮演 提交于 2020-06-25 08:53:22
问题 The simplest question for which I can't find an answer. I have an asp.net core 2.1 MVC application with Razor. Application widely uses ~/path syntax. Everything works great if application runs from domain root (for example, from http://localhost:5000/) But when I run application at non-root (for example, http://localhost:5000/app) the Razor still uses root ( / ) as base path. Question: how to configure this? How to specify base path for Razor's ~/ ? There must be an environment variable for

How to change root path ~/ in Razor in asp.net core

空扰寡人 提交于 2020-06-25 08:53:15
问题 The simplest question for which I can't find an answer. I have an asp.net core 2.1 MVC application with Razor. Application widely uses ~/path syntax. Everything works great if application runs from domain root (for example, from http://localhost:5000/) But when I run application at non-root (for example, http://localhost:5000/app) the Razor still uses root ( / ) as base path. Question: how to configure this? How to specify base path for Razor's ~/ ? There must be an environment variable for

send multiple parameters to asp.net core 3 mvc action using post method

孤者浪人 提交于 2020-06-17 09:50:29
问题 There is problem in sending ajax requests that have multiple parameters to asp.net mvc core 3 action using http post method. the parameters do not bind. In dot net framework asp.net web api there was similar limitation but not in asp.net mvc actions. I want to know is there work around this in asp.net core 3 mvc or is this the new limitation? action: public string SomeAction([FromBody]string param1, [FromBody]IEnumerable<SomeType> param2, [FromBody]IEnumerable<SomeType> param3) { //param1 and

.Net Core 3.0 AJAX POST Body Always Null

倖福魔咒の 提交于 2020-06-16 17:07:40
问题 I've recently converted my project from .Net Framework 4.7 to .Net Core 3.0. I'm having trouble getting my AJAX post to work. Here is what's working in .Net Framework 4.7: View: @using (Ajax.BeginForm("Save", "Controller", new AjaxOptions() { HttpMethod = "Post", OnSuccess = "OnSaveSuccess", OnFailure = "OnFailure" }, new { Model })) { ... Model Code Here } Controller: [HttpPost] public JsonResult Save(Contract contract) Here's what is not working in .Net Core 3.0: View: <form method="post"

Always same culture: en-US

烂漫一生 提交于 2020-06-16 03:28:02
问题 I have an asp.net core project where I want to set the default language to nl-BE. For some reason it always take the language en-US See code below (ps: I created my own ApplicationLocalizer who fetched the resources from a database => works fine). Startup.cs public void ConfigureServices(IServiceCollection services) { //Add MVC services.AddMvc() .AddViewLocalization(); //Localization factory services.AddSingleton<IStringLocalizerFactory, ApplicationLocalizerFactory>(); ... } public void

Always same culture: en-US

China☆狼群 提交于 2020-06-16 03:27:37
问题 I have an asp.net core project where I want to set the default language to nl-BE. For some reason it always take the language en-US See code below (ps: I created my own ApplicationLocalizer who fetched the resources from a database => works fine). Startup.cs public void ConfigureServices(IServiceCollection services) { //Add MVC services.AddMvc() .AddViewLocalization(); //Localization factory services.AddSingleton<IStringLocalizerFactory, ApplicationLocalizerFactory>(); ... } public void

AddEntityFrameworkStores can only be called with a role that derives from IdentityRole in .NET Core 2.0

蓝咒 提交于 2020-06-13 17:34:48
问题 I have changed a project from the .NET Core 1.1 to 2.0 version, but I'm getting an error from the Identity, when It tries to add the stores: services.AddIdentity<ApplicationUser, IdentityRole<long>>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); The thrown error is: AddEntityFrameworkStores can only be called with a role that derives from IdentityRole These are my classes: public class ApplicationUser : IdentityUser<long> { } public class ApplicationDbContext

.Net Core Dependency Injection inject out of constructor [closed]

旧街凉风 提交于 2020-06-12 07:35:29
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago . I need to inject out of constructor, everything I declared in Setup. Ho can I do it ? How can I inject services out of constructor ? Something like Injector service in Angular 2. INJECT SERVICES WITHOUT CONSTRUCTOR IN CONTROLLERS something like this public class ControllerBase : Controller {

Using Asp.Net Core 2 Injection for Serilog with Multiple Projects

余生长醉 提交于 2020-06-09 10:28:44
问题 I have Serilog configured for Asp.Net Core 2.0 and it works great via .Net Core dependency injection in my startup web project (if I use it through Microsoft.Extensions.Logging), but I can't access it from any other project. Here's what I have: Program.cs using System; using System.IO; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Serilog; namespace ObApp.Web.Mvc { public class Program { public static IConfiguration

Using Asp.Net Core 2 Injection for Serilog with Multiple Projects

﹥>﹥吖頭↗ 提交于 2020-06-09 10:27:46
问题 I have Serilog configured for Asp.Net Core 2.0 and it works great via .Net Core dependency injection in my startup web project (if I use it through Microsoft.Extensions.Logging), but I can't access it from any other project. Here's what I have: Program.cs using System; using System.IO; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Serilog; namespace ObApp.Web.Mvc { public class Program { public static IConfiguration