3

I am using the ASP.Net Web API and I need to pass in a different number of parameters to the accions in my controllers, but I haven't found (I'm new to Web API) a specific way to indicate a route template for the different methods I might have in my controllers.

Currently I have this template.

      config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{action}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

I don't think I'll have to indicate a new template for each of the different methods I have in my controllers, do I?

As I told you, I'm really new to Web API and I haven't found much info about this , that's why I'd really apreciate if you could give me some advice or guidance.

EDIT

It seems that the best way to go will be passing in the parameters in the query string like this:

api/controller/action?parm1=val1&par2=val2&par3=val3  

the problem is that I have no idea how to put this in a route template or how to retrive these values from the query string.

1 Answer 1

1

Take a look at using The Route Attribute.

Attribute Routing

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.