簡體   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