1

Possible Duplicate:
Asp.Net MVC 2 - Bind a model's property to a different named value

Given following url:

~/mycontroller/myaction/?REG_NAME=123

following action:

public ActionResult MyAction(ActionRequest model)

and model:

public class ActionRequest
{
    [ThisIsTheAttributeNameImLookingFor("REG_NAME")]
    public string RegisteredTo { get; set;}
}

How can I map model's property (RegisteredTo) to url parameter (REG_NAME) with different name?

Inheriting CustomModelBinderAttribute is not the option, as it can not be applied to properties.

1
  • 2
    Yep, it's a duplicate. Although the second response is better, than the one marked as answer. Unless someone knows an easier way I vote to close. Commented Aug 26, 2011 at 13:39

2 Answers 2

0

No such attribute exists. You either use a custom model binder, or a custom TypeDescriptor.

Sign up to request clarification or add additional context in comments.

Comments

0

You can it like this:

public class ActionRequest
{
    private string REG_NAME { get; set;}

    public string RegisteredTo { get { return REG_NAME; } set { this.REG_NAME = value; } ;}
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.