0

I'm using the below model to bind the query string with my controller using [FromUri]

namespace MyApi.Models
{
    public class Product
    {
        public int Id { get; set; }
        public decimal Price { get; set; }
    }
}

The controller action method code is

public ActionResult ActionMethod1( [FromUri] Product product)

The URL incoming is http://myapplication:2020/ActionMethod1/?Id=1&Cost=20

Now, internally the Cost in the query param should be mapped to Price in the Product class.

How can I do that ? I know I can use custom model binding but instead something like,

Is there any attribute that I can apply to the above class? Something like,

[BindingName("Cost")]
public decimal Price {get;set}
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.