asp.net-core-mvc

after upgrade to .net core 3.0 error“No webpage was found for the web address: https://localhost:44374/”

妖精的绣舞 提交于 2020-01-25 00:19:05
问题 I upgrade my project that have 2 classes library and one Mvc project to MVC Core 3.0 from 2.2 whit this page enter link description here change .net <TargetFramework>netcoreapp3.0</TargetFramework> 2.change like this <ItemGroup> <!--<PackageReference Include="Microsoft.AspNetCore.App" />--> <!--<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />--> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0" /> <!--<PackageReference Include="Microsoft

Pass array of objects to controller by jQuery AJAX, action data is always null in ASP.NET Core 2.2 MVC - it is working with .NET Framework 4.5

半城伤御伤魂 提交于 2020-01-24 20:12:40
问题 I am working in project that I need to use ajax call to save object data from my page witch contain order details. When I use project with .NET framework version 4.5, it is working very well - but when I use ASP.NET Core MVC, it is not working. Any help please? I did try every thing in similar questions but they did not work. For example I use notation [frombody] - but I still have the same problem. I have the following controller action: public ActionResult CreateOrders([FromBody] T_POS_ENT

Pass array of objects to controller by jQuery AJAX, action data is always null in ASP.NET Core 2.2 MVC - it is working with .NET Framework 4.5

[亡魂溺海] 提交于 2020-01-24 20:11:11
问题 I am working in project that I need to use ajax call to save object data from my page witch contain order details. When I use project with .NET framework version 4.5, it is working very well - but when I use ASP.NET Core MVC, it is not working. Any help please? I did try every thing in similar questions but they did not work. For example I use notation [frombody] - but I still have the same problem. I have the following controller action: public ActionResult CreateOrders([FromBody] T_POS_ENT

Registering routes with ASP.Net 5's MVC 6 Attribute Routing

╄→尐↘猪︶ㄣ 提交于 2020-01-24 10:28:05
问题 When using Attribute Routing in ASP.Net MVC 5 you would call the command routes.MapMvcAttributeRoutes(); and then just add the Route() tag to the Controller/Actions you wanted to build routes to. I am now trying to do this in ASP.Net MVC 6 and have found many pages that show you how to do it, which is really no different than in MVC 5, but they don't show you where or how to register those routes. Does ASP.Net MVC 6 just due it for you automatically or is there an equivalent to routes

Asp.Net MVC Core enabling double escape

一个人想着一个人 提交于 2020-01-24 03:25:30
问题 I am working on a asp.net mvc core application and trying to allow double escaping. My Edit url has a phone number as hyperlink (Ex: +123). I know how to do with a normal asp.net mvc application. I used to change web.config file as <system.webServer> <security> <requestFiltering allowDoubleEscaping="true"/> </security> </system.webServer> But I am right now on Asp.Net MVC Core application with out a web.config. How and where can I manage this? 回答1: ASP.NET Core application could be hosted on

How do I implement custom model validation in ASP.NET Core?

孤人 提交于 2020-01-24 02:00:07
问题 In previous versions of ASP.NET MVC the way to add custom validation to your model was by implementing the IValidatableObject and implementing your own Validate() method. As an example: public class BestModelEver : IValidatableObject { public DateTime? Birthday { get; set; } public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) { if (Birthday.HasValue) { yield return new ValidationResult("Error message goes here"); } } } Is this still the recommended way of adding

How to customize validation error message given by text-danger?

混江龙づ霸主 提交于 2020-01-23 07:34:48
问题 I have a dropdown list on one of my pages in my MVC .NET Core project that I want to customise the default validation text for. <select asp-for="ProductID" class="form-control" asp-items="ViewBag.ProductID"> <option value="">--Select Product --</option> </select> <span asp-validation-for="ProductID" class="text-danger" /> The standard validation error message given is "The Product ID field is required". I want to change this to something else. I have tried using this <span asp-validation-for=

How to customize validation error message given by text-danger?

橙三吉。 提交于 2020-01-23 07:34:03
问题 I have a dropdown list on one of my pages in my MVC .NET Core project that I want to customise the default validation text for. <select asp-for="ProductID" class="form-control" asp-items="ViewBag.ProductID"> <option value="">--Select Product --</option> </select> <span asp-validation-for="ProductID" class="text-danger" /> The standard validation error message given is "The Product ID field is required". I want to change this to something else. I have tried using this <span asp-validation-for=

ASP.NET Core Identity 2: User.IsInRole always returns false

与世无争的帅哥 提交于 2020-01-23 06:52:48
问题 The question: I call RoleManager.CreateAsync() and RoleManager.AddClaimAsync() to create roles and associated role claims. Then I call UserManager.AddToRoleAsync() to add users to those roles. But when the user logs in, neither the roles nor the associated claims show up in the ClaimsPrincipal (i.e. the Controller's User object). The upshot of this is that User.IsInRole() always returns false, and the collection of Claims returned by User.Claims doesn't contain the role claims, and the

ASP.NET Core Identity 2: User.IsInRole always returns false

强颜欢笑 提交于 2020-01-23 06:51:26
问题 The question: I call RoleManager.CreateAsync() and RoleManager.AddClaimAsync() to create roles and associated role claims. Then I call UserManager.AddToRoleAsync() to add users to those roles. But when the user logs in, neither the roles nor the associated claims show up in the ClaimsPrincipal (i.e. the Controller's User object). The upshot of this is that User.IsInRole() always returns false, and the collection of Claims returned by User.Claims doesn't contain the role claims, and the