Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7443201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:17:41+00:00 2026-05-29T11:17:41+00:00

I need a way to configure my contract (method) to take a variable number

  • 0

I need a way to configure my contract (method) to take a variable number of parameters. Because you should be able to pass 2 or 10 parameters to this end point.

Btw, the reason I return a Stream is because I serialize my data to XML manually (not important).

ServiceInterface:

[OperationContract]
Stream UpdateAgent(string token, string agentId, string newAgentName, string param1);

Service implementation:

[WebGet(UriTemplate = "/update_agent/{token}/{agentId}/{newAgentName}/{param1}")]
public Stream UpdateAgent(string token, string agentId, string newAgentName, string param1)
    {
        //do stuff here
    }

This method is only available with this URI request:

/update_agent/<long number of chars and numbers>/123456/John Silver/<some ID of associated data>

But I want to be able to pass more params of strings, if I want to. I know that alters the end point of the contract – but is this possible?

To clarify, the following should trigger the same endpoint:

/update_agent/<long number of chars and numbers>/123456/John Silver/dom_81/pos_23

/update_agent/<long number of chars and numbers>/123456/John Silver/dom_120/dat_12/pos_10

/update_agent/<long number of chars and numbers>/123456/John Silver/con_76

Can anyone help me – because clearly I can’t make 10,000 methods taking care of each extra parameter…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:17:42+00:00Added an answer on May 29, 2026 at 11:17 am

    I have solved my own problem, by doing the following:

    • Installing URL Rewrite 2.0 (link)
    • Configured a rewrite rule through my Web.config file:

    Web.config section: configuration/system.webServer/

    <rules>
        <rule name="UpdateAgentUrlRewrite" stopProcessing="true">
            <match url="^service/update_agent/([^/]+)/(agent_\d+)/([^/]+)/(.*)$" />
            <action type="Rewrite" url="Service.svc/update_agent/{R:1}/{R:2}/{R:3}?input={R:4}" appendQueryString="false" logRewrittenUrl="true" />
        </rule>
    </rules>
    

    This regex, I made, will transform an URL like this:

    /service/update_agent/123a456b789c012d/agent_1/New Agent Name/d_1/e_2/f_3/g_4

    ||

    /Service/update_agent/123a456b789c012d/agent_1/New%20Agent%20Name?input=d_1/e_2/f_3/g_4

    Which means I can hit the same Service Endpoint no matter how much I append in the URL, and then just extract the query parameters with this code:

    var context = WebOperationContext.Current;
    if(context != null)
    {
        NameValueCollection queryParams = context.IncomingRequest.UriTemplateMatch.QueryParameters;
        //contains a keyvalue pair:
        // {
        //  key = "input";
        //  value = "e_2/f_3/g_4";
        // }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a way to configure my scala application. Configgy seemed the way to
Need a way to allow sorting except for last item with in a list.
I need a way to easily export and then import data in a MySQL
I need a way to recursively delete a folder and its children. Is there
I need a way to update the month value on a dateTime field in
I need a way to bind POJO objects to an external entity, that could
I need a way to build C++ code from UML diagrams and vice versa.
I need a way to represent a 2-D array (a dense matrix) of doubles
I need a way to allow each letter of a word to rotate through
I need a way to determine the type of an HTML element in JavaScript.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.