modelbinder

how to sanitize input data in web api using anti xss attack

女生的网名这么多〃 提交于 2020-02-03 04:47:05
问题 Below is the snippet of my code Model class // Customer.cs using CommonLayer; namespace Models { public class Customer { public int Id { get; set; } [MyAntiXss] public string Name { get; set; } } } I want to sanitize the value in the 'Name' field of the Model class as below // CutstomModelBinder.cs using Microsoft.Security.Application; using System.ComponentModel; using System.Linq; using System.Web.Mvc; namespace CommonLayer { public class CutstomModelBinder : DefaultModelBinder { protected

Does the Model Binder in ASP.NET MVC Beta Support List<T>?

坚强是说给别人听的谎言 提交于 2019-12-18 05:48:28
问题 Take the example classes below. I want to display the customer and two addresses (from a LIST) on a form. Does the model binder in MVC beta support this or will I have to write my own custom binder? public class Customer { public string FirstName { get; set; } public string LastName { get; set; } public List<Address> Addresses { get; set; } public Customer() { Addresses = new List<Address>(); } } public class Address { public int Line1 { get; set; } public int Line2 { get; set; } public int

Model Binding within a Model Binder

柔情痞子 提交于 2019-12-06 15:15:07
问题 Firstly, bear with me here. I have a custom model binder which is successfully mapping form data to a custom object. Within this model binder it also maps form items to different custom object. What I feel I should be able to do is create a separate model binder to take care of this second mapping. This is a simplified version. Custom objects: public class Category { public int CategoryId { get; set; } public string Name { get; set; } public string Status { get; set; } public string

Model Binding within a Model Binder

我与影子孤独终老i 提交于 2019-12-04 22:03:12
Firstly, bear with me here. I have a custom model binder which is successfully mapping form data to a custom object. Within this model binder it also maps form items to different custom object. What I feel I should be able to do is create a separate model binder to take care of this second mapping. This is a simplified version. Custom objects: public class Category { public int CategoryId { get; set; } public string Name { get; set; } public string Status { get; set; } public string Description { get; set; } public IEnumerable<SubCategory> SubCategories { get; set; } } public class SubCategory

How to convert a http-request into the right object?

强颜欢笑 提交于 2019-12-01 20:40:56
问题 In my ASP.Net MVC3 project I have created a ModelBinder which binds a basemodel. In my View i create a object from a Model that inherit from my basemodel. Now i wan´t to know which Model was created via reflection in my ModelBinder when i press the submit-button, but how? ModelBinder: public class MBTestBinder : IModelBinder { public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { //need to know which Model was created -> convert into the right

How to convert a http-request into the right object?

我只是一个虾纸丫 提交于 2019-12-01 19:40:41
In my ASP.Net MVC3 project I have created a ModelBinder which binds a basemodel. In my View i create a object from a Model that inherit from my basemodel. Now i wan´t to know which Model was created via reflection in my ModelBinder when i press the submit-button, but how? ModelBinder: public class MBTestBinder : IModelBinder { public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { //need to know which Model was created -> convert into the right object //reflection? } } Models: [ModelBinder(typeof(MBTestBinder))] public class MBTest { public string

WebAPI ModelBinder Error

非 Y 不嫁゛ 提交于 2019-11-29 18:53:56
问题 I've implemented a ModelBinder but it's BindModel() method is not being called, and I get Error Code 500 with the following message: Error: Could not create a 'IModelBinder' from 'MyModelBinder'. Please ensure it derives from 'IModelBinder' and has a public parameterless constructor. I do derive from IModelBinder and do have public parameterless constructor. My ModelBinder Code: public class MyModelBinder : IModelBinder { public MyModelBinder() { } public bool BindModel

When do I use View Models, Partials, Templates and handle child bindings with MVC 3

╄→гoц情女王★ 提交于 2019-11-27 04:17:25
new to mvc3, i have a few questions, would appreciate if someone could answer/provide links: When should I use View Models? Is it not recommended to use the domain? I find that my view models are copies of my domain objects, and don't see the value... When should I use Partials? Is it only if the partial view will be reused? When should I use Display Templates and Editor Templates? Can I use these without a view model? How do I create an edit screen where the parent and list of child objects are both editable? i.e. a few fields at the top (parent) and a grid of fields below (like editable rows

When do I use View Models, Partials, Templates and handle child bindings with MVC 3

你离开我真会死。 提交于 2019-11-26 11:07:37
问题 new to mvc3, i have a few questions, would appreciate if someone could answer/provide links: When should I use View Models? Is it not recommended to use the domain? I find that my view models are copies of my domain objects, and don\'t see the value... When should I use Partials? Is it only if the partial view will be reused? When should I use Display Templates and Editor Templates? Can I use these without a view model? How do I create an edit screen where the parent and list of child objects