Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何将在https:下运行的.NETWeb服务公开给javascript?_Asp.net_Web Services_.net 4.0 - Fatal编程技术网

Asp.net 如何将在https:下运行的.NETWeb服务公开给javascript?

Asp.net 如何将在https:下运行的.NETWeb服务公开给javascript?,asp.net,web-services,.net-4.0,Asp.net,Web Services,.net 4.0,我将使用.Net的Scriptmanager向客户端javascript公开一个web服务,如下所示: <asp:ScriptManager ID="scriptMgr" runat="server"> <services> <asp:servicereference Path="RmUiControlDataSVC.svc" /> </services> </asp:ScriptManager> 当

我将使用.Net的Scriptmanager向客户端javascript公开一个web服务,如下所示:

 <asp:ScriptManager ID="scriptMgr" runat="server">
    <services>
        <asp:servicereference Path="RmUiControlDataSVC.svc" />
    </services>
</asp:ScriptManager>
当我从本地服务器上运行这个程序时,它工作正常,我可以在其中运行这些方法。当我远程部署并使用
http:
连接到我的站点(在我的站点上工作)时,它也会运行。但是,当我尝试使用
https:
连接到同一个应用程序时,就会出现问题(https://mysite.com/msftqa/RmMain.aspx). 现在,当我尝试访问服务的方法时,我得到一个

503服务不可用

通过Firebug进行检查发现,我的Svc正在尝试使用
http:
而不是
https:
进行绑定,因此无法找到该服务。下面是web.config的相关部分

  <service name="Company.App.RM.RmUiControlDataSVC">
    <endpoint address="" behaviorConfiguration="Company.App.RM.RmUiControlDataAspNetAjaxBehavior"
      binding="webHttpBinding" contract="Company.App.RM.RmUiControlDataSVC" />
  </service>


有没有一种方法可以让服务在通过https连接时使用
https:
,但在使用
http:
连接时仍能正常工作

通过http和https公开WCF意味着您需要两个端点。您可以通过声明或编程方式配置:


这正是我想要的。谢谢
  <service name="Company.App.RM.RmUiControlDataSVC">
    <endpoint address="" behaviorConfiguration="Company.App.RM.RmUiControlDataAspNetAjaxBehavior"
      binding="webHttpBinding" contract="Company.App.RM.RmUiControlDataSVC" />
  </service>