asp.net-mvc

ASP.NET MVC Core Tag Helper Issue

*爱你&永不变心* 提交于 2021-02-08 10:25:18
问题 I am having an issue using tag helpers in a form element. When I choose the "GET" HTTP method, the parameter for my Edit method in my Item controller won't get filled by the "hello" argument. However, when I choose the "POST" HTTP method, the parameter is filled correctly with "hello". Why is this happening? <form asp-controller="Item" asp-action="Edit" asp-route-item="hello" method="get"> <input type="submit" /> </form> And here is the controller: [HttpGet] [HttpPost] public IActionResult

ASP.NET MVC ScriptBundle: change rendered output

百般思念 提交于 2021-02-08 10:19:26
问题 Is it possible to change the rendered output of a ScriptBundle in ASP.NET MVC? When configuring the bundles with EnableOptimizations = false , the output for each script included in the bundle is something like this: <script src="~/Scripts/path/to/script"></script> I would like to change this "template" based on the ScriptBundle (for all bundles would also be fine). Is there a way to change this? 回答1: Have a look at the below code, which will always give fresh file. using System.IO; using

ASP.NET MVC ScriptBundle: change rendered output

一个人想着一个人 提交于 2021-02-08 10:15:22
问题 Is it possible to change the rendered output of a ScriptBundle in ASP.NET MVC? When configuring the bundles with EnableOptimizations = false , the output for each script included in the bundle is something like this: <script src="~/Scripts/path/to/script"></script> I would like to change this "template" based on the ScriptBundle (for all bundles would also be fine). Is there a way to change this? 回答1: Have a look at the below code, which will always give fresh file. using System.IO; using

MVC Custom Routing only for GET requests

强颜欢笑 提交于 2021-02-08 10:13:12
问题 I have a custom routing class which I added to the RouteConfig public static class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.Add(new CustomRouting()); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } } The CustomRouting class looks like this: public class CustomRouting : RouteBase { public override

ModelState.IsValid always true when accessed on View

China☆狼群 提交于 2021-02-08 10:12:07
问题 By following this i got the ModelState.IsValid ins jquery code. but it is always true, i can see the error on my page. What i am trying to achieve is show loading when a form is submitted. I used onclick event of submit. It shows loading even if there are validation errors on page. I don't wanna show loading in this case. I also tried using Form 's Submit event but same results. My ViewModel is having DataAnnotations for validations and form is in a partial view. Any suggestions how can i

ModelState.IsValid always true when accessed on View

人走茶凉 提交于 2021-02-08 10:11:18
问题 By following this i got the ModelState.IsValid ins jquery code. but it is always true, i can see the error on my page. What i am trying to achieve is show loading when a form is submitted. I used onclick event of submit. It shows loading even if there are validation errors on page. I don't wanna show loading in this case. I also tried using Form 's Submit event but same results. My ViewModel is having DataAnnotations for validations and form is in a partial view. Any suggestions how can i

How to push MySQL Database Data to a MVC .NET web application

早过忘川 提交于 2021-02-08 10:07:52
问题 I would like to know how I can push data changes in a MySQL database table to an MVC Web Application. So if the table changes - the web app gets updated .. I am not talking polling or querying - I am talking MySQL has a table changed - and that table data change gets sent to the Web App - clients. I see that SQL server seems to have some functionality built in (full version but not in express), I am not seeing this in MySQL database either (which is really what I need). 回答1: In SQL Server you

Multiple vs single database

╄→尐↘猪︶ㄣ 提交于 2021-02-08 08:56:18
问题 We are developing a new version of our web application. We have multiple clients (500+), each client has its own database with its own data: users, products... In the new version, all clients are going to share some data, for example, users are going to be in the platform but each client will be able to access to their users only, but instead of having the users for each client we want to have all the users in a centralize table. Other things such as products, orders...are going to belong to

After upgrade to asp.net 5.2.3, CORS isn't working for “*” origins

徘徊边缘 提交于 2021-02-08 08:43:18
问题 I have a project using web api and one using asp.net mvc. They are configured using CORS module. The project using Web Api is configured to allow any origin because it's deployed on Azure and it's an OData endpoint, so we don't know who is going to consume it. OData endpoint configuration // inside configuration config.EnableCors(); // controllers [EnableCors(origins: "*", headers: "*", methods: "*")] [Authorize] [HttpPost] public void ... From my MVC client, using Angular $http we issue an

Jquery to Check ModelState is Valid or not

橙三吉。 提交于 2021-02-08 07:29:33
问题 I want to check whether the ModelState is Valid or not through jquery. In My scenario if he click on submit button, and the fields fulfilled the requirement of Required Attributes, i want to open model popover, otherwise we want to show the errors, can any one tell me how to check ModelState is valid or not? 回答1: For this I think you have two ways of working around. First you can simply make a ajax post to your controller (say: public JsonResult IsModelStateValid(YourModel model) { return