2

I want to transfer a string aray in my url to a mvc controller .

My controller method is

public ActionResult Index(MyModel model)

and I want My model to be

public class TagEditRequestVM
{
    public string ValueA { get; set; }

    public List<string> MyList { get; set; }
}

what is the best url structure to call it?

1

1 Answer 1

3

You have to use an index and the []-notation:

http://host/Controller/Index?ValueA=val&MyList[0]=item1&MyList[1]=item2

THe index hasn't to be an incrementing integer - it just has to be unique.

EDIT

Ok, thanks to the link plurby writes in his comment you can leave out the bracket notation and just repeat the property name:

http://host/Controller/Index?ValueA=val&MyList=item1&MyList=item2
Sign up to request clarification or add additional context in comments.

Comments

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.