N
N
Nikita072021-07-02 07:06:25
ASP.NET
Nikita07, 2021-07-02 07:06:25

How to pass a parameter to the controller?

Hello everyone, the question is the following, I have such a controller

[HttpGet]
        public async Task<ContentResult> Auction([FromQuery(Name = "ids")] int[] ids, AuctionModel auctionModel)
        {
            var partners = _AdCampaignMsSqlBl.GetRtbPartners(ids);
            var result = await _rtbService.GetAuctionResult(partners.Values, auctionModel);

            return new ContentResult
            {
                Content = result,
                ContentType = "application/xml",
                StatusCode = 200
            };
        }

which takes an array of ids as parameters and fills the model using ModelBinder, but now I need to pass another parameter of type string, which will have the following format "1-1-1" (instead of 1 there may be other numbers, but they will all be separated sign '-') how can I do this, please tell me

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-07-02
@vabka

1. Make a string parameter and parse it in the controller
2. Make a non-string parameter and parse it with ModelBinder

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question