最近開始使用AngularJS+ASP.NET WebAPI做專案
restful webapi 雖定義了GET/POST/PUT/DELETE 但並無標準web service 的wdsl 可以產生xml 文件
此時需安裝套件以自動產生help page,開發筆記如下:

1.使用nuget安裝套件helppage

Package Manager Console> Install-Package Microsoft.AspNet.WebApi.HelpPage

2.使用/// 快速鍵,將controller之action 等級加上說明

/// <summary>
/// 刪除外撥主檔
/// </summary>
/// <param name="outboundIdRoot"></param>
/// <returns></returns>
public bool Delete(string outboundIdRoot)
{
    OutboundProgramBLL outboundProgramBLL = new OutboundProgramBLL();
    return outboundProgramBLL.Delete(outboundIdRoot); ;
}

3.專案屬性
輸出:XML文件檔案:App_Data\Document.XML

4.設定使用Document.XML
修改~Area/HelpPage/App_Start/HelpPageConfig.cs           

  public static void Register(HttpConfiguration config)
        {
        //// Uncomment the following to use the documentation from XML documentation file.
            config.SetDocumentationProvider(
new XmlDocumentationProvider(
HttpContext.Current.Server.MapPath("~/App_Data/Document.XML")));
            //...
            //...
        }


5.F6重新編譯 專案

7.使用http://xxxxxx/help  查看helppage


 










arrow
arrow
    全站熱搜

    michaelfang 發表在 痞客邦 留言(0) 人氣()