繁体   English   中英

“/”应用程序中的服务器错误。 无法找到该资源。 (404) 将 WCF 服务部署到 Azure 应用服务时

[英]Server Error in '/' Application. The resource cannot be found. (404) when deploying WCF service to Azure App Service

我正在创建一个 WCF 服务来将一些数据存储在我正在制作的 Xamarin.Forms 应用程序中。 我已将此服务部署到 Azure 应用服务。 导航到 URL 时出现以下错误:

Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /EventWCFService.svc

WCF 服务的代码隐藏:

 public class EventWCFService : IEventWCFService
    {
        private static IEventService _eventService = new EventService(new EventRepository());
        public void AddEvent(Event @event)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(@event.EventTitle) || @event == null)
                {
                    throw new FaultException("Event name is required");
                }

                _eventService.AddEvent(@event);
            }
            catch (Exception exception)
            {
                throw new FaultException($"Whoops... Something has gone wrong {exception.Message}");
            }
        }
        public IList<Event> GetAllEvents()
        {
            return _eventService.GetAllEvents();
        }
    }

我的 WCF 项目还包含存储库和服务:

在此处输入图像描述

IEventWCF服务:

 [ServiceContract]
    public interface IEventWCFService
    {
        [OperationContract]
        IList<Event> GetAllEvents();
        [OperationContract]
        void AddEvent(Event @event);
    }

Web.配置:

<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.8" />
    <httpRuntime targetFramework="4.8"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

我尝试过的事情:

  1. 首先,我尝试将 go 到属性并创建一个虚拟目录 - 没有工作或解决问题。

  2. 我试图将“特定页面”设置为空白 - 它仍然没有解决问题。

  3. 我试图创建一个新的应用服务 - 但我仍然遇到了问题。

我对 WCF 很陌生 - 如果这可能是一个新手错误,我深表歉意。 我正在学习 Pluralsight 课程,在 Azure 部署部分之前我相处得很好。

我通过直接从 Azure 门户而不是 Visual Studio 本身创建和部署新的 Azure 应用服务解决了这个问题。 然后 - 我直接从我刚刚创建的现有应用服务部署了 WCF 服务。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM