C# WCF服务在本地工作,在远程服务器上返回404未找到

C# WCF服务在本地工作,在远程服务器上返回404未找到,c#,wcf,server,http-status-code-404,C#,Wcf,Server,Http Status Code 404,您好,我正在寻找许多类似的问题,我没有找到答案,请您帮助我。我的wcf服务在本地机器上运行良好,在远程服务上它为我提供404。这是我的网页配置 <?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=16

您好,我正在寻找许多类似的问题,我没有找到答案,请您帮助我。我的wcf服务在本地机器上运行良好,在远程服务上它为我提供404。这是我的网页配置

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>

  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <appSettings>
    <add key="GoogleAnalytics:PropertyID" value="" />
    <add key="webpages:Version" value="3.0" />
    <add key="webpages:Enabled" value="true" />
    <add key="vs:EnableBrowserLink" value="false" />
  </appSettings>

    <system.web>
      <compilation debug="true" targetFramework="4.5.1" />
      <httpRuntime targetFramework="4.5.1" />
      <customErrors mode="Off"/>
      <securityPolicy>
        <trustLevel name="Full" policyFile="internal"/>
      </securityPolicy> 
    </system.web>

  <system.web.webPages.razor>
    <host factoryType="System.Web.WebPages.Razor.WebRazorHostFactory, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.WebPages.WebPage">
      <namespaces>
        <add namespace="System.Web.Configuration" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>


  <location path="crossdomain.xml">
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
      <modules runAllManagedModulesForAllRequests="true" /> 
    </system.webServer>
  </location> 
    <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed"></binding>
      </webHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="ServiceBehaviour" name="App.RozankaWeb.Service.EmailService">
        <endpoint address="http:/mydomain.com/Service/EmailService.svc" behaviorConfiguration="web" binding="webHttpBinding" contract="App.RozankaWeb.Service.IEmailService" />
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
      <serviceActivations>
        <add relativeAddress="Service/EmailService.svc" service="App.RozankaWeb.Service.EmailService"/>
      </serviceActivations>
    </serviceHostingEnvironment>
  </system.serviceModel>
</configuration>
这是我的服务

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.Text;

namespace App.RozankaWeb.Service
{
  public class EmailService : IEmailService
  {

    public void SendEmail(PostEmail postEmail)
    {

      MailAddress from = new MailAddress(postEmail.emailFrom, postEmail.emailFromName);
      MailAddress to = new MailAddress(postEmail.emailTo, postEmail.emailToName);
      MailMessage message = new MailMessage(from, to);
      message.Subject = postEmail.subject;
      message.Body = postEmail.body;

      SmtpClient client = new SmtpClient
      {
        Host = "smtp.mydomain.com",
        Port = 587,
        UseDefaultCredentials = false,
        Credentials = new NetworkCredential("mycredential@.com", "mypassword"),
        DeliveryMethod = SmtpDeliveryMethod.Network,
        EnableSsl = true,
        Timeout = 10000
      };

      Console.WriteLine("Sending an e-mail message to {0} and {1}.", to.DisplayName, message.Bcc.ToString());
      try
      {

        ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
          return true;
        };
        client.Send(message);
      }
      catch (Exception ex)
      {
        Console.WriteLine("Exception caught in CreateBccTestMessage(): {0}",
                    ex.ToString());
      }

    }

  }

  public class PostEmail
  {

    public string emailTo;
    public string emailToName;
    public string subject;
    public string body;
    public string emailFrom;
    public string emailFromName;
    public bool isBodyHtml;

  }

}
和我的界面

{
  [ServiceContract]
  public interface IEmailService
  {
    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "SendEmail", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
    void SendEmail(PostEmail postEmail);

  }
}

我知道这是很多代码,但请查看并提供帮助,我非常感谢您的帮助:

首先,您的绑定和应用程序池设置是否正确?第二,您的域是否配置良好?如果您没有使用IP,那么将以下内容粘贴到浏览器中会发生什么情况http:///Service/EmailService.svc 当我跟踪链接时,将服务器名替换为主机名http:///Service/EmailService.svc 服务开始下载我不认为这个绑定存在basicHttpsBinding,只是听说了basicHttpBinding。
{
  [ServiceContract]
  public interface IEmailService
  {
    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "SendEmail", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
    void SendEmail(PostEmail postEmail);

  }
}