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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:18:55+00:00 2026-06-12T20:18:55+00:00

I have a controller named LoginController with a Get method with a signature of:

  • 0

I have a controller named LoginController with a Get method with a signature of:

public string Get(string Key, string Code, string UserID, string Password)

I want to be be able to invoke it with a call similar to:

http://localhost:1234/api/Login/KeyValue/CodeValue/UserValue/PasswordValue

I cannot get this to work. If I invoke the call with:

http://localhost:1234/api/Login?Key=KeyValue&Code=CodeValueUserID=UserValue&Password=PasswordValue 

The call is successful.

I’ve tried adding routes such as below to Global.asax

 routes.MapHttpRoute(name: "Login", routeTemplate: "api/{controller}/{action}/{Key}/{Code}/{UserID}/{Password}",
                defaults: new { Key = UrlParameter.Optional, Code = UrlParameter.Optional, UserID = UrlParameter.Optional, Password = UrlParameter.Optional });

or

 routes.MapHttpRoute(name: "Login", routeTemplate: "api/{controller}/{Key}/{Code}/{UserID}/{Password}",
                defaults: new { Key = UrlParameter.Optional, Code = UrlParameter.Optional, UserID = UrlParameter.Optional, Password = UrlParameter.Optional });

These do not seem to work. Where am I going wrong or is this even possible? I was able to do this in the RC version of WebApi with MVC3.

  • 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-12T20:18:56+00:00Added an answer on June 12, 2026 at 8:18 pm

    It seems you are missing the action in your request (/api/Login/KeyValue/CodeValue/UserValue/PasswordValue).
    Try /api/Login/Get/KeyValue/CodeValue/UserValue/PasswordValue instead, if you intend to use the first route.

    If you want to be able to call it without the action specified and default to “Get”, you have to specify a default action:

    defaults: new { Key = UrlParameter.Optional, Code = UrlParameter.Optional, UserID = UrlParameter.Optional, Password = UrlParameter.Optional, Action = "Get" }
    

    I have successfully tried this in an ASP.NET MVC 4 project (Visual Studio 2012 RC):

    Creating a LoginController with action:

    public string Get(string Key, string Code, string UserID, string Password)
    {
        return Key + Code + UserID + Password;
    }
    

    And mapping the route in Global.asax.cs:

     RouteTable.Routes.MapHttpRoute(null, "api/{controller}/{Key}/{Code}/{UserID}/{Password}",
                new { Key = UrlParameter.Optional, Code = UrlParameter.Optional, UserID = UrlParameter.Optional, Password = UrlParameter.Optional, Action = "Get"});
    

    If it is not working for you, maybe another route is catching the request or the route is not being registered.

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

Sidebar

Related Questions

lets say I have a controller named Store. There is an index method: public
I have the following controller: public ActionResult Search(string Name, int? Friend, int? Page) It
I have a controller named BearController. In it I have one index action method
If one where to have a controller named UsersController with an action like: public
I have a controller named store_controller.rb and method index that renders index.html.erb , displaying
Using Spring MVC, I have this Controller class: @Controller public class LoginController { @Autowired
Suppose, I have a controller named category with an action method, Index which takes
I have a controller named Content, which has an Index action, which is associated
I have a Controller named Author . Inside the controller, I have defined a
i have a controller named PagesController which used to have an action named contest

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.