asp.net-core-mvc-2.1

Submit a Form using AJAX in ASP.Net Core MVC

本秂侑毒 提交于 2021-02-05 20:31:11
问题 I am working with ASP.Net Core 2.1, and trying to upload a file while returning it's url, without refreshing the page. I am trying to write the JavaScript in site.js as the _RenderPartial("scripts") renders all scripts at the end of the page and hence directly using script tag in the razor view is not working. Secondly, adding it to site.js gives me an opportunity to call the script across the site views. My Controller action looks like : [HttpPost] [DisableRequestSizeLimit] public async Task

Submit a Form using AJAX in ASP.Net Core MVC

▼魔方 西西 提交于 2021-02-05 20:31:06
问题 I am working with ASP.Net Core 2.1, and trying to upload a file while returning it's url, without refreshing the page. I am trying to write the JavaScript in site.js as the _RenderPartial("scripts") renders all scripts at the end of the page and hence directly using script tag in the razor view is not working. Secondly, adding it to site.js gives me an opportunity to call the script across the site views. My Controller action looks like : [HttpPost] [DisableRequestSizeLimit] public async Task

Pagination and Pages conflict - ASP.Net Core Razor Pages conflicts with MVC controller method pagination

一个人想着一个人 提交于 2019-12-23 22:26:16
问题 In an ASP.Net Core 2.1 with Angular 6 spa project, I return a paginated list of users using this AccountController.cs method: [HttpGet("users")] [Produces(typeof(List<UserViewModel>))] public async Task<IActionResult> GetUsers() { return await GetUsers(-1, -1); } [HttpGet("users/{page:int}/{pageSize:int}")] <---- conflicts here [Produces(typeof(List<UserViewModel>))] public async Task<IActionResult> GetUsers(int page, int pageSize) { var users = await _accountManager.GetUsersLoadRelatedAsync

ASP.NET Core MVC - empty string to null when sending JSON to server

∥☆過路亽.° 提交于 2019-12-11 08:13:18
问题 When posting input data as a FormData to the ASP.NET Core MVC controller, by default empty string values are coerced to null values. However, when sending input data as JSON to the controller, empty string values remain as they are. This leads to different behavior when validating string properties. For example, description field is not bound to null , but to empty string on the server: { value: 1, description: "" } This in turn makes following model invalid, even though Description is not

How do I resolve version conflicts in aspnet core 2.1? (2.1.1 >= 2.1.0-rc1-final)

孤街浪徒 提交于 2019-12-08 13:32:36
Trying to add Microsoft.VisualStudio.Web.BrowserLink 2.1.1 as a nuget package on a very stock File -> New -> Project .net core 2.1 project. Version conflict detected for Microsoft.AspNetCore.Hosting.Abstractions. Reference the package directly from the project to resolve this issue. EngineeringWeb (>= 1.0.0) -> Microsoft.VisualStudio.Web.BrowserLink (>= 2.1.1) -> Microsoft.AspNetCore.Hosting.Abstractions (>= 2.1.1) EngineeringWeb (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0-rc1-final) -> Microsoft.AspNetCore.Hosting.Abstractions (>= 2.1.0-rc1-final). I recall doing things in csproj files

How do I resolve version conflicts in aspnet core 2.1? (2.1.1 >= 2.1.0-rc1-final)

半城伤御伤魂 提交于 2019-12-08 05:09:56
问题 Trying to add Microsoft.VisualStudio.Web.BrowserLink 2.1.1 as a nuget package on a very stock File -> New -> Project .net core 2.1 project. Version conflict detected for Microsoft.AspNetCore.Hosting.Abstractions. Reference the package directly from the project to resolve this issue. EngineeringWeb (>= 1.0.0) -> Microsoft.VisualStudio.Web.BrowserLink (>= 2.1.1) -> Microsoft.AspNetCore.Hosting.Abstractions (>= 2.1.1) EngineeringWeb (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0-rc1-final) ->