Last active
August 29, 2015 14:25
-
-
Save jfreyre/ab2facc7e57811d5a081 to your computer and use it in GitHub Desktop.
How to list all availables routes from a webapi application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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