Asp.net

.asmx Web 服務文件

  • July 15, 2014

我希望我的摘要、參數資訊、返回資訊等(如下所列)顯示在 .net 為 .asmx Web 服務生成的標準幫助頁面上。

/// <summary>
/// Brief description
/// </summary>
/// <param name="fakeParamOne">Fake Param One Description</param>
/// <returns>Bool representing foo</returns>

我嘗試過的唯一以任何方式影響自動生成的幫助頁面的是:

[WebMethod(Description = "Does awesome things.")]

我確定我錯過了一些非常簡單的東西(或者不可能做我想做的事)。有什麼建議麼?

就像@John Saunders 評論提到的那樣,實際上並沒有一種自動方式來使用 XML 方法評論顯示在 WSDL 幫助中,但是有幾個替代方法可以得到您正在尋找的內容。

WebMethod描述屬性可以設置為格式化HTML

這是一個例子:

const string someWebMethodDescription = @"
<table>
   <tr>
       <td>Summary:</td><td>[My Summary]</td>
   </tr>
   <tr>
       <td>Parameters:</td><td> </td>
   </tr>
   <tr>
       <td>fakeParam:</td><td>[My Fake Param Description]</td>
   </tr>
</table>";

[WebMethod(Description=someWebMethodDescription)]
public List<string> SomeWebMethod

結果在哪裡:

具有自定義 HTML 描述的 Web 方法

或者,創建自定義 WSDL 幫助頁面

<configuration>
  <system.web>
     <webServices>
        <wsdlHelpGenerator href="docs/HelpPage.aspx"/>
     </webServices>
  </system.web>
</configuration>

檢查此程式碼項目文章以獲取有關製作自己的幫助頁面的詳細資訊:

改進 ASP.NET Web 服務幫助生成器以反映繼承

引用自:https://stackoverflow.com/questions/6390806