asp.net-core-mvc

Validation Form With Ajax in Asp.net Core

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-18 13:06:42
问题 I use AJAX to send forms to controller in ASP.NET Core but I have problem with send form with validation <form asp-action="Create" asp-controller="Departments" data-ajax="true" data-ajax-method="Post" data-ajax-mode="replace" data-ajax-update="#content" data-ajax-success="Success" data-ajax-failure="Failure"> <div class="box-body"> <div class="alert alert-success" id="divalert" ></div> <div class="form-group"> <label asp-for="Title" class="control-label"></label> <input asp-for="Title" class=

Validation Form With Ajax in Asp.net Core

守給你的承諾、 提交于 2021-02-18 13:04:05
问题 I use AJAX to send forms to controller in ASP.NET Core but I have problem with send form with validation <form asp-action="Create" asp-controller="Departments" data-ajax="true" data-ajax-method="Post" data-ajax-mode="replace" data-ajax-update="#content" data-ajax-success="Success" data-ajax-failure="Failure"> <div class="box-body"> <div class="alert alert-success" id="divalert" ></div> <div class="form-group"> <label asp-for="Title" class="control-label"></label> <input asp-for="Title" class=

How to publish ASP.NET Core app to ftp server

浪子不回头ぞ 提交于 2021-02-18 06:31:52
问题 Visual Studio publish only supports importing web deploy. Is there a workaround? 回答1: Visual Studio publishing profiles supports pure FTP as a target. It does not support SFTP however. These are the options you should see: Web Deploy Web Deploy Package FTP (does not support SFTP unfortunately) File System (UNC or local path) Update since noted ASP.NET 5 With the details that the project is ASP.NET 5 / vNext, at this time, FTP and Web Deploy are not supported yet in the UI of Visual Studio.

Redirect URI sent as HTTP and not HTTPS in app running HTTPS

戏子无情 提交于 2021-02-17 21:35:10
问题 I have an Asp .net core MVC app. Which connects to an Identity Server 4 for authentication. Hosted in a docker swarm MVC app is hosted on https://XXXXXXX ConfigurServies services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme) .AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, options

Redirect URI sent as HTTP and not HTTPS in app running HTTPS

房东的猫 提交于 2021-02-17 21:35:01
问题 I have an Asp .net core MVC app. Which connects to an Identity Server 4 for authentication. Hosted in a docker swarm MVC app is hosted on https://XXXXXXX ConfigurServies services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme) .AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, options

Invalid state cookie. An error was encountered while handling the remote login. ASP.NET Core MVC external social login

旧时模样 提交于 2021-02-16 09:37:29
问题 While implementing external social login in ASP.NET Core2.2 MVC web application without ASP.NET Core Identity. I am getting below error while redirecting back to the application after successful sign in with Google, Facebook, Twitter, LinkedIn and Microsoft. An unhandled exception occurred while processing the request. Exception: Invalid state cookie. Unknown location Exception: An error was encountered while handling the remote login. Microsoft.AspNetCore.Authentication

Invalid state cookie. An error was encountered while handling the remote login. ASP.NET Core MVC external social login

喜夏-厌秋 提交于 2021-02-16 09:37:06
问题 While implementing external social login in ASP.NET Core2.2 MVC web application without ASP.NET Core Identity. I am getting below error while redirecting back to the application after successful sign in with Google, Facebook, Twitter, LinkedIn and Microsoft. An unhandled exception occurred while processing the request. Exception: Invalid state cookie. Unknown location Exception: An error was encountered while handling the remote login. Microsoft.AspNetCore.Authentication

When methods have the name …Async the exception “System.InvalidOperationException: No route matches the supplied values” occurs

核能气质少年 提交于 2021-02-11 15:40:43
问题 Steps to reproduce: Create a new Web API project Create a UsersController with the following code . [ApiController] [Route("[controller]")] public class UsersController : ControllerBase { [HttpGet("{id:int}", Name = nameof(GetUserByIdAsync))] public async Task<ActionResult<object>> GetUserByIdAsync([FromRoute] int id) { object user = null; return Ok(user); } [HttpPost] public async Task<ActionResult<object>> CreateUserAsync() { object user = null; return CreatedAtAction(nameof

How can i create a multi level menu in MVC core?

守給你的承諾、 提交于 2021-02-10 14:33:19
问题 The HTML menu rendered from my helper function is Category 1 Category 2 Category 2 Category 3 Category 4 I have set Category 2 as a child category of Category 1 . Unfortunately, the current HTML helper displays again Category 2 as a parent afterwards. Id ParentCategoryId Description 1 NULL Category 1 2 1 Category 2 3 NULL Category 3 4 NULL Category 4 5 NULL Category 5 How should I modify my helper function? @{ Func<dynamic, IHtmlContent> ShowMenu(List<Category> cats) => @<ul> @foreach (var

How to check if a section in MVC Core configuration file exist?

丶灬走出姿态 提交于 2021-02-10 12:49:08
问题 How can I check if a specific section in loaded ASP.NET Core configuration file exist? I have a JSON configuration file that I load it in Startup class via ConfigurationBuilder.AddJsonFile method. This JSON file is an array with this layout: { "Url": "", "Regex": [ "", "" ], "Keys": { "Title": "", "Description": "", "Keywords": [ "" ] } } But some of them doesn't have Keys . I tried to check return type of section.GetSection("Keys") against null , But it doesn't return null even if Keys