ASP.NET Web API or MVC routing

Posted on 2012-09-14
Last Modified: 2012-09-17

I am new to both MVC and ASP.NET Web API.  I now have created a Web API project and everything is moving nicely except routing.  I am used to writing web services where I name my methods as I like and they called easily by clients.  Now I have a controller with


I need to add a

GetCustomersForShop(string key, int shopId);

But it keeps mapped to the GetAllCustomers(); method

I have not changed my routing in the web api config as I don't understand how that works.  Can anyone help please

Question by:gbzhhu
    LVL 38

    Accepted Solution

    Generally the convention is [controller]/[action]?[parameterstring]

    So in your case, if your controller is called CustomerController.cs and you want to access the GetCustomersForShop(string key, int shopId); method, then you need the URL:
    LVL 12

    Author Closing Comment

    Thank you.  That sorted it

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now