gpt4 book ai didi

asp.net-mvc - 发布到 Azure 时出现 '/' 应用程序中的服务器错误

转载 作者:行者123 更新时间:2023-12-03 04:34:18 24 4
gpt4 key购买 nike

我已从之前的 NopCommerce 网站之一复制了源代码,复制并重命名了 Azure 上的数据库,并更新了 settings.txt 文件以指向新数据库。唯一的其他更改是 CSS。

当我在本地主机上运行新站点时,它工作得很好,没有任何问题,但是,当我从 VS 发布到 Azure,然后浏览到 URL 时,我收到错误 - “/”应用程序中的服务器错误。我一生都无法弄清楚这一点,并且想知道是否还有其他人经历过这一点。

我使用的是 Nop 3.5

我的直觉告诉我我的连接字符串有问题,但是,为什么在本地主机上可以工作但在发布时却不行?...

下面是异常详细信息和堆栈跟踪

预先感谢您的帮助

“/”应用程序中的服务器错误。参数“nameOrConnectionString”不能为 null、为空或仅包含空格。描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

异常详细信息:System.ArgumentException:参数“nameOrConnectionString”不能为 null、空或仅包含空格。

来源错误:

生成此未处理异常的源代码只能在 Debug模式下编译时显示。要启用此功能,请按照以下步骤之一操作,然后请求 URL:

  1. 在生成错误的文件顶部添加“Debug=true”指令。示例:

或者:

2) 将以下部分添加到应用程序的配置文件中:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

请注意,第二种技术将导致给定应用程序中的所有文件在 Debug模式下进行编译。第一种技术将导致仅在 Debug模式下编译该特定文件。

重要提示:在 Debug模式下运行应用程序确实会产生内存/性能开销。您应该确保应用程序在部署到生产场景之前已禁用调试。

堆栈跟踪:

[ArgumentException: The argument 'nameOrConnectionString' cannot be null, empty or contain only white space.]
System.Data.Entity.Utilities.Check.NotEmpty(String value, String parameterName) +61
System.Data.Entity.DbContext..ctor(String nameOrConnectionString) +22
Nop.Web.Framework.<>c__DisplayClass15.<Register>b__9(IComponentContext c) +42
Autofac.<>c__DisplayClass10`1.<Register>b__f(IComponentContext c, IEnumerable`1 p) +10
Autofac.Builder.<>c__DisplayClass1`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p) +14
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +32
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +31
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +185
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +31
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +185
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +31
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +185
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +74
Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) +54
Autofac.ResolutionExtensions.Resolve(IComponentContext context, IEnumerable`1 parameters) +118
Nop.Web.Framework.SettingsSource.<BuildRegistration>b__5(IComponentContext c, IEnumerable`1 p) +35
Autofac.Builder.<>c__DisplayClass1`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p) +14
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +32
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +44

[DependencyResolutionException: An exception was thrown while executing a resolve operation. See the InnerException for details. ---> The argument 'nameOrConnectionString' cannot be null, empty or contain only white space. (See inner exception for details.)]
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +112
Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +108
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +74
Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) +54
Autofac.ResolutionExtensions.Resolve(IComponentContext context, IEnumerable`1 parameters) +118
Autofac.ResolutionExtensions.Resolve(IComponentContext context) +46
Nop.Core.Infrastructure.DependencyManagement.ContainerManager.Resolve(String key, ILifetimeScope scope) +89
Nop.Core.Infrastructure.NopEngine.Resolve() +55
FoxNetSoft.Plugin.Misc.RFQ2.UpdateStartUpTask.Execute() +34
Nop.Core.Infrastructure.NopEngine.RunStartupTasks() +477
Nop.Core.Infrastructure.NopEngine.Initialize(NopConfig config) +36
Nop.Core.Infrastructure.EngineContext.Initialize(Boolean forceRecreate) +92
Nop.Web.MvcApplication.Application_Start() +30

[HttpException (0x80004005): An exception was thrown while executing a resolve operation. See the InnerException for details. ---> The argument 'nameOrConnectionString' cannot be null, empty or contain only white space. (See inner exception for details.)]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9916673
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): An exception was thrown while executing a resolve operation. See the InnerException for details. ---> The argument 'nameOrConnectionString' cannot be null, empty or contain only white space. (See inner exception for details.)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

版本信息:Microsoft .NET Framework 版本:4.0.30319; ASP.NET版本:4.0.30319.36215

更新

从我的评论中的链接我认为我需要在下面定义连接字符串?来自 NopObjectContext.cs

namespace Nop.Data
{
/// <summary>
/// Object context
/// </summary>
public class NopObjectContext : DbContext, IDbContext
{
#region Ctor

public NopObjectContext(string nameOrConnectionString)
: base(nameOrConnectionString)
{
//((IObjectContextAdapter) this).ObjectContext.ContextOptions.LazyLoadingEnabled = true;
}
}
}

最佳答案

在 NopCommerce 中,连接字符串在名为 Settings.txt 的文件中设置,该文件位于 Presnetation\Nop.Web\App_Data 文件夹中。但它不是解决方案的一部分,因此不会部署。您可以:

  1. 手动发布该文件。
  2. 将该文件添加到您的 Nop.Web 项目并进行部署。

关于asp.net-mvc - 发布到 Azure 时出现 '/' 应用程序中的服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29743095/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com