2011-10-31 24 views
1

我上傳nopcommerce解決方案到appharbor(使用這種方法Can't build notcommerce project under appharbor)和解決方案成功地建立,但我收到403錯誤 - 禁止:訪問嘗試打開頁面時被拒絕(允許寫訪問文件系統設置爲真)。AppHarbor NopCommerce運行問題

感謝,並希望對你有所幫助

+0

您是否嘗試過下載構建輸出以確定AppHarbor是否正在部署您期望的內容? – friism

+0

我下載了build,看起來好像一切正​​常。在根目錄下有已編譯的文件,_PublishedWebsite文件夾(有兩個文件夾:Nop.Admin和Nop.Web)。我會嘗試在本地運行所有源代碼,並在幾分鐘內回覆:) –

+0

ok我將下載的目錄添加到本地IIS,並且我收到HTTP錯誤403.14 - 禁止 Web服務器配置爲不列出此目錄的內容。 –

回答

2

的問題是,標準NopCommerce解決方案包含兩個Web項目。 AppHarbor僅爲每個應用程序部署一個Web項目,在這種情況下,我們恰好部署了Nop.Admin,這不是您想要的。

要解決此問題,您應該利用AppHarbor solution file convention並創建一個AppHarbor.sln解決方案文件,該文件僅引用Nop.Web項目。

2

我們在我們的基礎控制器中使用包裝來確保我們的所有代碼都不會忽略端口改變。

首先,修復Webhelper.cs:75

public virtual string GetThisPageUrl(bool includeQueryString, bool useSsl) 
     { 
      string url = string.Empty; 
      if (_httpContext == null) 
       return url; 

      if (includeQueryString) 
      { 
       string storeHost = GetStoreHost(useSsl); 
       if (storeHost.EndsWith("/")) 
        storeHost = storeHost.Substring(0, storeHost.Length - 1); 
       url = storeHost + _httpContext.Request.RawUrl; 
      } 
      else 
      { 
#if DEBUG 
       var uri = _httpContext.Request.Url; 

#else 
       //Since appharbor changes port number due to multiple servers, we need to ensure port = 80 as in AppHarborRequesWrapper.cs 
       var uri = new UriBuilder 
       { 
        Scheme = _httpContext.Request.Url.Scheme, 
        Host = _httpContext.Request.Url.Host, 
        Port = 80, 
        Path = _httpContext.Request.Url.AbsolutePath, 
        Fragment = _httpContext.Request.Url.Fragment, 
        Query = _httpContext.Request.Url.Query.Replace("?", "") 
       }.Uri; 
#endif 
       url = uri.GetLeftPart(UriPartial.Path); 
      } 
      url = url.ToLowerInvariant(); 
      return url; 
     } 

所以我們所做的僅僅是從https://gist.github.com/1158264添加文件到Nop.Core \ AppHarbor

和修改的基本控制器:

  • nopcommerce \ Presentation \ Nop.Web \ Controllers \ BaseNopController.cs

    public class BaseNopController : Controller 
    { 
        protected override void Initialize(RequestContext requestContext) 
        { 
         //Source: https://gist.github.com/1158264 
         base.Initialize(new RequestContext(new AppHarborHttpContextWrapper(System.Web.HttpContext.Current), 
                  requestContext.RouteData)); 
        } 
        //Same file from here downwards... 
    } 
    
  • nopcommerce \演示\ Nop.Web.Admin \ \控制器BaseNopController.cs

    public class BaseNopController : Controller 
    { 
    protected override void Initialize(System.Web.Routing.RequestContext requestContext) 
    { 
        //set work context to admin mode 
        EngineContext.Current.Resolve<IWorkContext>().IsAdmin = true; 
    
        //Source: https://gist.github.com/1158264 
        base.Initialize(new RequestContext(new AppHarborHttpContextWrapper(System.Web.HttpContext.Current), requestContext.RouteData)); 
    
        //base.Initialize(requestContext); 
    } 
        //Same file from here downwards... 
    } 
    
+0

謝謝。我會在這個週末嘗試你的解決方案。如果所有人都能正常工作,那麼就可以找到答案:) –

+0

在AH上NC會帶來什麼好運? – Korayem

1

在IIS快遞啓用目錄瀏覽功能

注意此方法是針對Web開發人員誰在使用IIS Express時遇到此問題。

要這樣做,請按照下列步驟操作: 打開命令提示符,然後轉到計算機上的IIS Express文件夾。例如,轉到以下文件夾中的一個命令提示符: C:\ Program Files文件\ IIS快遞 鍵入以下命令,然後按ENTER鍵: appcmd設置配置/部分:directoryBrowse /啓用:真

refrence :https://support.microsoft.com/en-us/kb/942062