Wednesday, January 18, 2017

WebAPI start up page on deployment.

1. Properties --> Build --> Xml documentation file :  App_Data/XmlDocument.xml

2. HelpPageConfig.cs

 config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));


3. HelpPageAreaRegistration.cs

 public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "HelpPage_Default",
                "Help/{action}/{apiId}",
                new { controller = "Help", action = "Index", apiId = UrlParameter.Optional });

            context.MapRoute(
            "Help Area",
            "",
            new { controller = "Help", action = "Index" }
            );
            HelpPageConfig.Register(GlobalConfiguration.Configuration);
        }

4. Make sure all documentation exists:

        /// <summary>
        /// Get all products from web api call
        /// </summary>
        /// <param name="data">data</param>
        /// <returns></returns>
        [Route("products")]
        [HttpPost]
        public async Task<IHttpActionResult> GetProducts([FromBody] IDictionary<string, string> data)


5. in _Viewstart page
Layout = "~/Areas/HelpPage/Views/Shared/_Layout.cshtml";
Done:-)

No comments:

Post a Comment

Encrypt/Decrypt the App.Config

Program.cs using System; using System.Diagnostics; using System.IO; namespace EncryptAppConfig {     internal class Program     {         pr...