Protect .net Web Service URL

☆樱花仙子☆ 提交于 2020-01-13 03:36:06

问题


I have created Web Service using Asp.net 3.5. Now it's working perfectly in live windows server, and giving me perfect xml while invoking it using some url like :

http://www.somedomain.com/Service.asmx?op=fetchData

Now My question is when I am accessing url like :

http://www.somedomain.com/Service.asmx

it's listing my created web services.

What if I don't wanna list down the available web services to end users.

Thanks in advance...


回答1:


If you just want to disable the service help page then add the following to the system.web section of web.config:

<webServices>
   <wsdlHelpGenerator href="HideServices.aspx"/>
</webServices>

where HideServices.aspx is a page that contains the content you want to display when someone tries to browse http://www.somedomain.com/Service.asmx (it could be blank or a generic message).

The above config does leave WSDL generation enabled via ?WSDL (http://www.somedomain.com/Service.asmx?WSDL). If you also don't want to serve up your WSDL then instead add the following to the system.web section of web.config:

<webServices>
  <protocols>
    <remove name="Documentation" />
  </protocols>
</webServices>


来源:https://stackoverflow.com/questions/2598763/protect-net-web-service-url

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