Skip to content

Instantly share code, notes, and snippets.

@jfreyre
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfreyre/ab2facc7e57811d5a081 to your computer and use it in GitHub Desktop.
Save jfreyre/ab2facc7e57811d5a081 to your computer and use it in GitHub Desktop.
How to list all availables routes from a webapi application
#region Usings
using System;
using System.Web;
using System.Web.Helpers;
using System.Web.Http;
using System.Web.Http.Description;
using System.Web.Mvc;
#endregion Usings
namespace JFR.SampleApp
{
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
var _ApiExplorer = GlobalConfiguration.Configuration.Services.GetApiExplorer();
foreach (var _Api in _ApiExplorer.ApiDescriptions)
{
System.Diagnostics.Debug.WriteLine("-----------------------------------------------------------");
System.Diagnostics.Debug.WriteLine("Uri path: {0}", _Api.RelativePath);
System.Diagnostics.Debug.WriteLine("HTTP method: {0}", _Api.HttpMethod);
foreach (var _Parameter in _Api.ParameterDescriptions)
{
System.Diagnostics.Debug.WriteLine("Parameter: {0} - {1}", _Parameter.Name, _Parameter.Source);
}
Console.WriteLine();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment