0

我正在尝试将我的 ASP 应用程序部署到虚拟主机,但收到以下错误

System.ArgumentException: Invalid value for key 'attachdbfilename'.

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

[ArgumentException: Invalid value for key 'attachdbfilename'.]
   System.Data.SqlClient.SqlConnectionString.VerifyLocalHostAndFixup(String& host, Boolean enforceLocalHost, Boolean fixup) +907214
   System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +4116
   System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24
   System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +150
   System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +59
   System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4
   System.Data.SqlClient.SqlConnection..ctor(String connectionString) +26
   System.Data.Entity.Infrastructure.SqlConnectionFactory.CreateConnection(String nameOrConnectionString) +236
   System.Data.Entity.Infrastructure.LocalDbConnectionFactory.CreateConnection(String nameOrConnectionString) +281
   System.Data.Entity.Internal.LazyInternalConnection.Initialize() +327
   System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName() +13
   System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +332
   System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18
   System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +56
   System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
   System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +37
   System.Linq.Queryable.OrderByDescending(IQueryable`1 source, Expression`1 keySelector) +66
   georgi_it2.Models.ApplicationController..ctor() +302
   georgi_it2.Controllers.HomeController..ctor() +5

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +67

[InvalidOperationException: An error occurred when trying to create a controller of type 'georgi_it2.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +182
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +80
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +218
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +49
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970436
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

公司提供给我的连接字符串是这样的:

<add name="SiteSqlServer" connectionString="Server=(127.0.0.1);Database=DATABASENAME;uid=DBUSERNAME;pwd=DBPASSWORD;" providerName="System.Data.SqlClient" />

我的 web.config 文件中的那个是一样的。我已经创建了一个数据库,它与我机器上的默认连接字符串配合得很好。

4

1 回答 1

0

一种可能的原因:

我在使用 WebSecurity 类进行身份验证时遇到了这个错误。检查用于帐户控制器的过滤器文件夹中的属性类。此类用于初始化 WebSecurity 类,但具有引用“DefaultConnection”的默认构造函数调用。将其更改为 web.config 的连接字符串部分中的连接字符串的名称(在您的情况下为“SiteSqlServer”),它可能会解决问题。

于 2013-03-10T22:19:27.810 回答