首页新闻找找看学习计划

asp.net mvc4.0+ef 发布到IIS 服务器上Invalid value for key 'attachdbfilename',跪求大神!

0
悬赏园豆:100 [已关闭问题] 关闭于 2016-02-03 18:06

数据库 sql server2008 r2,iis7在同一个服务器上

在本地调试正常,发布到本地访问服务器数据库正常。

程序放到服务器上访问服务器上数据库,访问报错Invalid value for key 'attachdbfilename'。

度娘上都是字符串什么的,完全不明白。。。

等大神解答。。。。

错误信息:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Invalid value for key 'attachdbfilename'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace

for more information about the error and where it originated in the code.

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

Source Error:

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.  

Stack Trace:


[ArgumentException: Invalid value for key 'attachdbfilename'.]
   System.Data.SqlClient.SqlConnectionString.VerifyLocalHostAndFixup(String& host, Boolean enforceLocalHost, Boolean fixup)

+897526
   System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +4085
   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.Entity.Infrastructure.Interception.DbConnectionDispatcher.<SetConnectionString>b__18(DbConnection t,

DbConnectionPropertyInterceptionContext`1 c) +14
   System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Action`2 operation,

TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +73
   System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.SetConnectionString(DbConnection connection,

DbConnectionPropertyInterceptionContext`1 interceptionContext) +364
   System.Data.Entity.Infrastructure.SqlConnectionFactory.CreateConnection(String nameOrConnectionString) +420
   System.Data.Entity.Infrastructure.LocalDbConnectionFactory.CreateConnection(String nameOrConnectionString) +284
   System.Data.Entity.Internal.LazyInternalConnection.Initialize() +313
   System.Data.Entity.Internal.LazyInternalConnection.get_Connection() +13
   System.Data.Entity.Internal.LazyInternalContext.get_Connection() +93
   DAL.DbContextBase..ctor(String connectionString) +35
   Log.LogDbContext..ctor() +29
   DAL.AfocusShopDbContext..ctor() +46
   BLL.AfocusShopService.Login(String loginName, String password) +130
   Castle.Proxies.Invocations.IAfocusShopService_Login.InvokeMethodOnTarget() +139
   Castle.DynamicProxy.AbstractInvocation.Proceed() +91
   Core.Service.InvokeInterceptor.Intercept(IInvocation invocation) +197
   Castle.DynamicProxy.AbstractInvocation.Proceed() +132
   Castle.Proxies.IAfocusShopServiceProxy.Login(String loginName, String password) +150
   WebPc.Areas.Admin.Controllers.AccountController.Login(String username, String password) +35
   lambda_method(Closure , ControllerBase , Object[] ) +157
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +205
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor

actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +50
   System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +58
   System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +237
   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +126
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +45
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +61
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +49
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +28
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +49
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8836977
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

东—_—东的主页 东—_—东 | 初学一级 | 园豆:109
提问于:2015-12-29 18:10
< >
分享
所有回答(6)
0

你的数据库是用的附加文件吧,把web.config里的配置改改,直接连接sql server上的数据库。

liqipeng | 园豆:1160 (小虾三级) | 2015-12-29 18:21

直接建的数据库,web.config里没有数据库连接字符串,是另一个XML文件,没有用attachdbfilename这个属性。

支持(0) 反对(0) 东—_—东 | 园豆:109 (初学一级) | 2015-12-29 18:41
0

用了EF框架,metacontext文件自动生成之类的。

既然度娘都说了还是不明白,那只能是报告给你的小伙伴或上级来解决吧。

火力还不够。

arg | 园豆:1047 (小虾三级) | 2015-12-29 18:49

没有上级,自己一条龙服务

支持(0) 反对(0) 东—_—东 | 园豆:109 (初学一级) | 2015-12-29 18:59
0

attachdbfilename  按字面的意思是这个键有问题。看看你的maping和上下文里是否写对,本地的数据库和服务器上的数据库版本是否一致呢?

贫民窟大侠 | 园豆:4270 (老鸟四级) | 2015-12-30 09:25

在本机发布后,访问的就是服务器上数据库,正常。发布到服务器上,访问报错。

支持(0) 反对(0) 东—_—东 | 园豆:109 (初学一级) | 2015-12-30 10:09
0

看你发布的配置,项目重新生成后,在发布

搁忆 | 园豆:600 (小虾三级) | 2015-12-30 12:20
0

可能是访问到了iis的webconfig文件了,你可以打开Management下的Configuration Editor,看一下connectionStrings的值是多少,我部署到IIS的时候也被这个配置给坑过。

nil | 园豆:660 (小虾三级) | 2016-01-21 15:21
0

升级了.NET版本

东—_—东 | 园豆:109 (初学一级) | 2016-02-03 18:05
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册