1

I uploaded nopcommerce solution to appharbor (using this method Can't build notcommerce project under appharbor) and solution succesfully builded, but I receiving 403 error - Forbidden: Access is denied when trying to open page(Allow write-access to file system is set to true).

Thanks and hope for your help

Community
  • 1
  • 1
Yaroslav Bigus
  • 678
  • 7
  • 24
  • Have you tried downloading the build output to determine whether AppHarbor is deploying what you expect? – friism Oct 31 '11 at 18:42
  • I downloaded build and it looks like all ok. There are compiled files in root, _PublishedWebsite folder (with 2 folders: Nop.Admin and Nop.Web ). I'll try run all sources locally and will answer in a few minutes :) – Yaroslav Bigus Oct 31 '11 at 19:03
  • ok I added downloaded directory to local IIS and I receiving there HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory. – Yaroslav Bigus Oct 31 '11 at 19:39
  • 1
    Since the `_PublishedWebsite` folder contains two folders, it's likely that AppHarbor deploys the wrong site (Nop.Admin). To get around this, you should only include the Nop.Web project in your AppHarbor.sln. After that is resolved, you might encounter this issue: http://www.nopcommerce.com/boards/t/1093/redirect-loop.aspx?p=2 -- In general you might want to consider the build-local approach mentioned in this guide: http://support.appharbor.com/kb/tips-and-tricks/running-orchard-on-appharbor – friism Nov 01 '11 at 00:09

3 Answers3

2

We use a wrapper in our base controller to ensure that all of our code is oblivious to appharbor port changing.

First, fix in 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;
        }

So what we did is simply add files from https://gist.github.com/1158264 into Nop.Core\AppHarbor

and modified base controllers:

  • 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\Presentation\Nop.Web.Admin\Controllers\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...
    }
    
Korayem
  • 12,108
  • 5
  • 69
  • 56
2

The problem is that the standard NopCommerce solution contains two Web Projects. AppHarbor only deploys one web project per application, and in this case, we happen to deploy Nop.Admin which is not what you want.

To resolve this, you should take advantage of the AppHarbor solution file convention and create an AppHarbor.sln solution file that only references the Nop.Web project.

friism
  • 19,068
  • 5
  • 80
  • 116
1

Enable the Directory Browsing feature in IIS Express

Note This method is for the web developers who experience the issue when they use IIS Express.

To do this, follow these steps: Open a command prompt, and then go to the IIS Express folder on your computer. For example, go to the following folder in a command prompt: C:\Program Files\IIS Express Type the following command, and then press Enter: appcmd set config /section:directoryBrowse /enabled:true

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