model-binding

ASP.NET Core 3.1 cannot process Axios request until ApiController attribute is added

橙三吉。 提交于 2021-02-11 13:47:46
问题 I have the following issue. Whenever I send something to my Api endpoint, ASP.NET Core 3.1 is not able to process the request. However, when I add the ApiController attribute it works perfectly fine. My code is correct but only works when I add this attribute. How is that so? For reference, here's my code API [ApiController] //Remove this and the code breaks [Route("api/SomeApi")] public class ApiController : Controller { private readonly IService service; public ApiController(IService

Pass data from angular form to another controller

≡放荡痞女 提交于 2021-02-08 11:19:31
问题 I am new to angularjs. I want to pass data from html form to another route. Here is the part of index.html <div ng-app="myApp" ng-controller="HomeController"> <div class="container"> <div class="row"> <div class="col-md-12"> <div ng-view=""></div> </div> </div> </div> </div> Here are the routes var myApp = angular.module('myApp', ['ngRoute']); myApp.config(['$routeProvider', function ($routeProvider) { $routeProvider.when('/', { templateUrl: 'views/home.html', controller: 'HomeController' });

Can't bind property from model to control on XML view

半城伤御伤魂 提交于 2021-02-08 10:40:20
问题 I trying to migrate my app on new version of Openui5 (1.48) and have some problems with model bindings. I am using sap.ui.getCore().setModel(oModel, "local") for model declaration and when I trying to bind some controls to values from this model like this: <Text text="{local>/count}"/> value isn't displayed but if I will get this model, set it to view in controller and remove > from xml var oModel = sap.ui.getCore().getModel("local"); this.getView().setModel(oModel); XML <Text text="{/count}"

How to Refresh the Bindings on HomePageViewModel when some data has been changed in Navigated Page2

眉间皱痕 提交于 2021-01-29 11:29:47
问题 I have some property which I am using from Page2 in HomePageViewModel, When I navigate to Page2 I have changed that property and on coming back by doing NavigiationPop. HomePage is not re-loaded/ refreshed at all as I have set the BindingContext in the constructor of HomePage, which is loaded only once. The solution which is working for me is Setting the BindingContext to the ViewModel on "onAppearing()", usually its not consider the best practice. But I also need to refresh the values which

Understanding ASP.NET MVC Lifecycle: Why is Model not available in ActionFilter?

人走茶凉 提交于 2021-01-29 09:14:50
问题 I have created the following Custom ActionFilter, when I try to access the Model in the following code, it is null: public class CustomPermissionCheckAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext context) { OrganisationBaseController orgBaseController = context.Controller as Controller; var vm = ((Controller)context.Controller).ViewData.Model as MyViewModel; // null // check if current user has permission to vm.OrganisationId base

Validation of properties that require the values of other properties

六眼飞鱼酱① 提交于 2021-01-29 03:36:56
问题 So I have checked out this answer ASP:NET MVC 4 dynamic validation of a property depending of the current value of another property and it does not cover the issue I am having. I am using server side validation. I have a requirement that... A value is only required if another property is specified Issue MVC binds each property and calls each validator on that property as it binds them. If I am dependent on multiple properties being set when I check validationContext.ObjectInstance.[MY

Post with int/string (simple type) in body to asp.net core web api 2.1 not working

允我心安 提交于 2021-01-21 07:16:32
问题 I'm simply having no luck sending an url encoded form value from postman to a vanilla asp.net core 2.1 web api created with file->new project. I do nothing to it whatsoever but still the new model validation feature seems to kick in and returns a 400 Bad Request to postman. Can anyone tell me what I'm doing wrong? Controller Action: // POST api/values [HttpPost] public void Post([FromBody] string value) { } Raw request (as seen in fiddler): POST http://localhost:60843/api/values HTTP/1.1

ASP.NET MVC Model Binding with jQuery ajax request

。_饼干妹妹 提交于 2020-12-29 04:43:45
问题 I have a server side object in my MVC code that looks like this: class Person { public long Id { get; set; } public string Name { get; set; } public IList<Friend> Friends { get; set; } } class Friend { public long Id { get; set; } public string Name { get; set; } } From the jQuery client, I am making an ajax request and sending the following data (line breaks introduced for readability): var personId = $(... var personName = $(... var friends = []; // array of associative arrays for (var i =