1

How to invoke the WepApi Controller Action in browser URL, Below is the Action Method in APIController.

public virtual HttpResponseMessage Export(string ABC, string product, string Release, bool includeInheritedData = false)
{

}
1
  • what is the route map for the Api? Commented May 13, 2016 at 12:14

2 Answers 2

1

you can define route path and name for web api methods. Using that route can access a API controller action if it is simple Get call and has Anonymous access.

For example:

Suppose this a method in your API controller:

[HttpGet,AllowAnonymous][Route("api/register")]
public void Register()
  {

  }

You can access it in the URL like: localhost/api/register from browser.This is a simple example to explain thing in simple terms. There are lot of other things involved accessing API methods depending upon various factors like security, requirements etc.

Sign up to request clarification or add additional context in comments.

1 Comment

It Worked by accessing , localhost/Api/controllername/ManExport. Anyway thanks for your reply.
0

Already its predefined in Appstart/WebApiConfig.cs for WebApi controllers they were using like below.

        config.Routes.MapHttpRoute("DefaultApiWithId", "Api/{controller}/{id}", new { id = RouteParameter.Optional }, new { id = @"\d+" });
        config.Routes.MapHttpRoute("DefaultApiWithAction", "Api/{controller}/{action}");
        config.Routes.MapHttpRoute("DefaultApiGet", "Api/{controller}", new { action = "Get" }, new { httpMethod = new HttpMethodConstraint(HttpMethod.Get) });
        config.Routes.MapHttpRoute("DefaultApiPost", "Api/{controller}", new { action = "Post" }, new { httpMethod = new HttpMethodConstraint(HttpMethod.Post) });

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.