asp.net-core-mvc

ASP.Net Core register Controller at runtime

不羁的心 提交于 2020-04-07 12:02:50
问题 I am asking myself if it is possible to load a DLL with Controller s in it at runtime and use it. The only solution I've found is to add an assembly via ApplicationPart on the StartUp : var builder = services.AddMvc(); builder.AddApplicationPart( AssemblyLoadContext.Default.LoadFromAssemblyPath( @"PATH\ExternalControllers.dll" )); Do anyone know if it is possible to register Controller at any time, because the issue with that solution is, that you have to restart the WebService when you want

ASP.Net Core register Controller at runtime

故事扮演 提交于 2020-04-07 12:02:07
问题 I am asking myself if it is possible to load a DLL with Controller s in it at runtime and use it. The only solution I've found is to add an assembly via ApplicationPart on the StartUp : var builder = services.AddMvc(); builder.AddApplicationPart( AssemblyLoadContext.Default.LoadFromAssemblyPath( @"PATH\ExternalControllers.dll" )); Do anyone know if it is possible to register Controller at any time, because the issue with that solution is, that you have to restart the WebService when you want

Change default format for DateTime parsing in ASP.NET Core

此生再无相见时 提交于 2020-04-05 08:41:23
问题 I get a Date in an ASP.NET Core Controller like this: public class MyController:Controller{ public IActionResult Test(DateTime date) { } } The framework is able to parse the date, but only in English format. When I pass 04.12.2017 as date parameter, I mean the 4th of december 2017. This would get parsed as english date, so my date object gets the value 12th of April 2017. I tried adding german only using this article and also this, but without success. What needs to be done that ASP.NET Core

Change default format for DateTime parsing in ASP.NET Core

两盒软妹~` 提交于 2020-04-05 08:41:18
问题 I get a Date in an ASP.NET Core Controller like this: public class MyController:Controller{ public IActionResult Test(DateTime date) { } } The framework is able to parse the date, but only in English format. When I pass 04.12.2017 as date parameter, I mean the 4th of december 2017. This would get parsed as english date, so my date object gets the value 12th of April 2017. I tried adding german only using this article and also this, but without success. What needs to be done that ASP.NET Core

How to make a get request for an HTML file using ASP.NET Core MVC

ε祈祈猫儿з 提交于 2020-03-26 04:48:21
问题 I am making an ASP.NET Core MVC project. I have a HomeController set up, I have the Views folder with the Home and Shared folders set up, and inside those I have the appropriate .cshtml files (such as Index.cshtml, _Layout.cshtml, and _ViewStart.cshtml). I also have a PartialViews folder which has a bunch of HTML files (not .cshtml files). All I want to do is make an Ajax get request from the browser for an HTML file in the PartialViews folder (which, just to be clear, has the path MyProject

Object reference not set to an instance of an object ViewData[“Title”] = “Index”;

放肆的年华 提交于 2020-03-24 00:29:16
问题 So I'm trying to create a register razor page in my index page using a modal. Most of the form code that I imported into the modal is from the existing external register page. When I start up the mvc app, though, I receive a Object reference not set to an instance of an object error. Any help would be appreciated. Thanks! Console: System.NullReferenceException: Object reference not set to an instance of an object.at AspNetCore.Views_Home_Index.ExecuteAsync() in C:\Users\SalvadorSolis\source

where is DbContextTransaction in .Net Core

假装没事ソ 提交于 2020-03-24 00:06:18
问题 I need to use DbContextTransaction in a class on a .Net Standard library, I haven't been able to find the corresponding nuget package, I am porting this https://github.com/mehdime/DbContextScope/tree/master/Mehdime.Entity to .Net Core, but I only have 2 compilation errores due to missing packages/dependencies which I am not sure how to find: Error CS0246: The type or namespace name 'MarshalByRefObject' could not be found (are you missing a using directive or an assembly reference?) (CS0246)

ASP.net MVC core RedirectToPage error - specify root relative path error

浪子不回头ぞ 提交于 2020-03-21 19:08:08
问题 I want to redirect to a razor page from a normal controller action like this: return RedirectToPage("Edit", new { id = blogId }); I have already a razor page named "Edit" which is working when navigating to it normally: With RedirectToPage I get the following error: InvalidOperationException: The relative page path 'Edit' can only be used while executing a Razor Page. Specify a root relative path with a leading '/' to generate a URL outside of a Razor Page. Any idea how to specify that path?

ASP.net MVC core RedirectToPage error - specify root relative path error

大城市里の小女人 提交于 2020-03-21 19:08:08
问题 I want to redirect to a razor page from a normal controller action like this: return RedirectToPage("Edit", new { id = blogId }); I have already a razor page named "Edit" which is working when navigating to it normally: With RedirectToPage I get the following error: InvalidOperationException: The relative page path 'Edit' can only be used while executing a Razor Page. Specify a root relative path with a leading '/' to generate a URL outside of a Razor Page. Any idea how to specify that path?

.Net Core 3 IStringLocalizer.WithCulture(CultureInfo) is obsolete

被刻印的时光 ゝ 提交于 2020-03-21 11:34:11
问题 I've upgraded a project from .Net Core 2.2 to .Net Core 3.0. After trying to fix all the warnings and errors I'm now trying to fund a solution to this warning: 'IStringLocalizer.WithCulture(CultureInfo)' is obsolete: 'This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.' I'm using this to change the website language per the logged-in user. I have this implementation to change the website culture per user: public class CultureLocalizer : ICultureLocalizer { private