AppHarbor NopCommerce运行问题

发布于 2024-12-12 13:30:10 字数 264 浏览 0 评论 0原文

我将nopcommerce解决方案上传到appharbor(使用此方法无法在appharbor下构建notcommerce项目)和解决方案成功构建,但我收到 403 错误 - 禁止:尝试打开页面时访问被拒绝(允许对文件系统的写访问设置为 true)。

感谢并希望您的帮助

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

天涯沦落人 2024-12-19 13:30:10

问题是标准的 NopCommerce 解决方案包含两个 Web 项目。 AppHarbor 只为每个应用程序部署一个 Web 项目,在这种情况下,我们碰巧部署了 Nop.Admin 这不是您想要的。

要解决此问题,您应该利用 AppHarbor解决方案文件约定并创建仅引用Nop.Web项目的AppHarbor.sln解决方案文件。

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.

奶气 2024-12-19 13:30:10

我们在基本控制器中使用包装器来确保我们的所有代码都不会注意到 appharbor 端口的更改。

首先,修复 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

    公共类 BaseNopController :控制器
    {
        protected override void Initialize(RequestContext requestContext)
        {
            //来源:https://gist.github.com/1158264
            base.Initialize(new RequestContext(new AppHarborHttpContextWrapper(System.Web.HttpContext.Current),
                                               requestContext.RouteData));
        }
        //从这里向下相同的文件...
    }
    
  • nopcommerce\Presentation\Nop.Web.Admin\Controllers\BaseNopController.cs

    公共类 BaseNopController :控制器
    {
    protected override void Initialize(System.Web.Routing.RequestContext requestContext)
    {
        //将工作上下文设置为管理模式
        EngineContext.Current.Resolve().IsAdmin = true;
    
        //来源:https://gist.github.com/1158264
        base.Initialize(new RequestContext(new AppHarborHttpContextWrapper(System.Web.HttpContext.Current), requestContext.RouteData));
    
        //base.Initialize(requestContext);
    }
        //从这里向下相同的文件...
    }
    

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...
    }
    
风柔一江水 2024-12-19 13:30:10

启用 IIS Express 中的目录浏览功能

注意 此方法适用于在使用 IIS Express 时遇到问题的 Web 开发人员。

为此,请按照下列步骤操作:
打开命令提示符,然后转到计算机上的 IIS Express 文件夹。例如,在命令提示符中转到以下文件夹:
C:\Program Files\IIS Express
键入以下命令,然后按 Enter:
appcmd set config /section:directoryBrowse /enabled:true

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文