ASP.Net web service - any way to disable the “Test/invoke” section?

扶醉桌前 提交于 2021-02-04 19:42:27

问题


I want to remove the "Test... Invoke" section from the top of my web service pages (partly because the word 'test' may make users mistakenly think they are not executing something in production when they click it!), but still allow HTTPGET/POST for API users.

Any idea how?


回答1:


Try add follow text in Web.Config (I checked it - in my test-case it works)

<system.web>
   <webServices>
        <protocols>
          <remove name="Documentation" />
        </protocols>
   </webServices>
</system.web>

http://msdn.microsoft.com/en-us/library/2tyf2t8t.aspx




回答2:


You are talking about *.asmx services, write?

Invoke available only when request is local, remote clients will see next message instead:

The test form is only available for requests from the local machine.

You can't modify this auto generated pages, but you might want to display custom page:

    <system.web>
        <webServices>
                 <wsdlHelpGenerator href="helpPage.aspx"></wsdlHelpGenerator>
        </webServices>
    </system.web>

In this case Wsdl still will be available at service.asmx?wsdl.



来源:https://stackoverflow.com/questions/17187978/asp-net-web-service-any-way-to-disable-the-test-invoke-section

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!