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

  • SEARCH
  • Home
  • 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 8284837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:15:32+00:00 2026-06-08T11:15:32+00:00

I am developing an application using ASP.Net Web API and to configure application routing,

  • 0

I am developing an application using ASP.Net Web API and to configure application routing, I’m following this method. But in my application, the url i want is the below. “http://localhost/MY/api/user/AllGridData/false/1342006446883/10/1/Id/desc”

I manually typed this url in my browser window and AllGridData method is fired. But when I access it from the application, it tries to access the url like below.
“http://localhost/MY/api/user/AllGridData?_search=false&nd=1342006446883&rows=10&page=1&sidx=Id&sord=desc”

So then the AllGridData method is not fired because of the following exception.
Failed to load resource: the server responded with a status of 400 (Bad Request) “http://localhost/MY/api/user/AllGridData?_search=false&nd=1342006446883&rows=10&page=1&sidx=Id&sord=desc”

My routing for this url in RouterConfig.cs is like this.

routes.MapHttpRoute(
            name: "LoadGridApi",
            routeTemplate: "api/{controller}/{action}/{_search}/{nd}/{rows}/{page}/{sidx}/{sord}",
            defaults: new { _search = UrlParameter.Optional, nd = UrlParameter.Optional, rows = UrlParameter.Optional, page = UrlParameter.Optional, sidx = UrlParameter.Optional, sord = UrlParameter.Optional }
        );

Hope you understand the problem. Ultimately what I want is to get the URL like below, so then it AllGridData method is fired.
“http://localhost/MY/api/user/AllGridData/false/1342006446883/10/1/Id/desc”

What am I doing wrong? Is it because of wrong routing code?

My AllGridData method is in a WebAPI controller, not in a MVC controller.

  • 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-06-08T11:15:33+00:00Added an answer on June 8, 2026 at 11:15 am

    thilok. I just tried something similar, with a simpler routing.

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

    and used jQuery getJson calls to call the following method.

    public IEnumerable<Organisation> Get(int id, int nd)
            {                        
                using (_unitOfWork)
                {
    

    I found that I was able to make calls using all the following Urls

    /api/organisations/2/3, /api/organisations/2?nd = 3 and /api/userorganisations/?id=2&nd=3

    This also worked when directly calling them from a browser window. (Chrome).

    What I have notice that you have wrong is that you have an extra placeholder for action {action}. This should not be there for WebApi routing. This is for MVC routing only. There is no concept of action for WebApi’s, as this is all handled by the HttpVerbs.

    Further information can be found here

    WebApi routing

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing web application using asp.net, but i want to work on asp
I'm developing a web application using asp.net 3.5. This application has a lot of
I am developing web-application using Google Maps API and ASP.NET Ajax. Here is my
We are developing a REST based application using Visual Studio 2010, using asp.net web
I'm developing a web application using ASP .NET MVC 1.0 and jQuery (including the
I am developing an ASP.Net MVC 3 Web application using Razor Views. I have
I am developing an ASP.Net MVC 3 Web application using Entity Framework 4.1 and
I am developing an ASP.Net MVC 3 Web application using Entity Framework 4.1, however,
I'm developing a web application using asp.net. There is a text box which contains
I'm developing a web application using asp.net Mvc 2 and NHibernate, and I'm paging

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.