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 9208049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:31:52+00:00 2026-06-18T00:31:52+00:00

I have an authenticate function in my company controller [ActionName(Authenticate)] [HttpGet] public bool Authenticate(Company

  • 0

I have an authenticate function in my company controller

    [ActionName("Authenticate")]
    [HttpGet]
    public bool Authenticate(Company company)
    {
        if (Uow.Companies.AuthenticateCompany(company))            
            return true;                
        return false;
    }

that is called using the following ajax query

$.ajax({ url: "/api/company/Authenticate", type: 'get', data: company })

company is a js object

Company: function (name, phoneNumber, password) {
    this.Name = name;
    this.PhoneNumber = phoneNumber;
    this.password = password;
}

var company = new Company($('#TextBoxCompanyName').val(),'00000000', $('#TextBoxCompanyPassword').val());

and my api route is as follows

    config.Routes.MapHttpRoute(
        name: "Action",
        routeTemplate: "api/{controller}/{action}"
    );

When the code runs the web api calls the following function in the company controller

 public Company Get(int id)
    {
        return Uow.Companies.GetById(id);
    }

How do I call a custom get function?

  • 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-18T00:31:54+00:00Added an answer on June 18, 2026 at 12:31 am

    Web.API tries to match the routes in the definition order.

    From Web API Routing and Actions/Routing and Action Selection

    The framework tries to match the segments in the URI path to the template. Literals in the template must match exactly. A placeholder matches any value, unless you specify constraints. The framework does not match other parts of the URI, such as the host name or the query parameters. The framework selects the first route in the route table that matches the URI.

    So the order of definition of the routes matter.

    You need to put your "Action" before the "DefaultApi"

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

    Otherwise the wep.api interprets your url /api/company/Authenticate as controller=company and id=Authenticate so it routes to your Get action.

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

Sidebar

Related Questions

I have an authenticate function. The user is automatically logged out after 30 minutes.
I have a function, authenticate() that uses $post() to retrieve a session key from
I have the following function in ZF1 login controller and works fine but cannot
I have a function in a controller, which needs to check whether the user
I have a Dll function with this signature: UInt32 Authenticate(uint8 *Key); I'm doing this
I'm trying to create an iOS (iPhone specific) app where users have to authenticate
We have used Shibboleth to authenticate users. It works great. The issue is that
I have a facebook app that I authenticate using a general-purpose authentification. Like this:
I have a Java app that can authenticate to LDAP by logging users into
I have an extension where I authenticate the user when they enable to app.

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.