首页新闻找找看学习计划

MVC4 在IIS上发布遇到错误,本地运行正常

0
悬赏园豆:50 [已解决问题] 解决于 2014-04-23 00:07

Directory lookup for the file "D:\IIS\Test\App_Data\aspnet-MvcApplication1-20140318213623.mdf" failed with the operating system error 2(系统找不到指定的文件。). CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

 

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: Directory lookup for the file "D:\IIS\Test\App_Data\aspnet-MvcApplication1-20140318213623.mdf" failed with the operating system error 2(系统找不到指定的文件。). CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
源错误:

行 35:                         {
行 36:                             // Create the SimpleMembership database without Entity Framework migration schema
行 37:                             ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
行 38:                         }
行 39:                     }

源文件: d:\WebSiteTest\MvcApplication1\MvcApplication1\Filters\InitializeSimpleMembershipAttribute.cs    行: 37

情义之印的主页 情义之印 | 初学一级 | 园豆:15
提问于:2014-03-18 22:37
< >
分享
最佳答案
0

应该就是文件夹权限的问题  试试把App_Data 的写权限 设给EveryOne.

收获园豆:30
gunsmoke | 老鸟四级 |园豆:3592 | 2014-04-08 11:56
其他回答(2)
0

把数据库文件复制到指定的目录。默认VS发布网站时数据库文件是不复制的

收获园豆:10
happydaily | 园豆:581 (小虾三级) | 2014-03-19 08:27

我是手动把发布的文件复制到服务器那里的,数据库的那个APP_data文件夹没动,在服务器提交的文件这些:bin  Content Images Scripts Views Global.asax Web.Config

支持(0) 反对(0) 情义之印 | 园豆:15 (初学一级) | 2014-03-19 11:23

@情义之印: aspnet-MvcApplication1-20140318213623.mdf这个文件服务器上有了吗?

支持(0) 反对(0) happydaily | 园豆:581 (小虾三级) | 2014-03-19 13:24
0

创建文件是否有足够权限?

D:\IIS\Test\App_Data\aspnet-MvcApplication1-20140318213623.mdf

是否存在?

收获园豆:10
月明时勤 | 园豆:746 (小虾三级) | 2014-03-19 09:22

“/”应用程序中的服务器错误。

Directory lookup for the file "C:\IIS\Test\TestMvc\App_Data\aspnet-MvcApplication1-20140319094015.mdf" failed with the operating system error 2(系统找不到指定的文件。). CREATE DATABASE failed. Some file names listed could not be created. Check related errors.              说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。            
异常详细信息: System.Data.SqlClient.SqlException: Directory lookup for the file "C:\IIS\Test\TestMvc\App_Data\aspnet-MvcApplication1-20140319094015.mdf" failed with the operating system error 2(系统找不到指定的文件。). CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
源错误:

执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。                  

堆栈跟踪:

[SqlException (0x80131904): Directory lookup for the file "C:\IIS\Test\TestMvc\App_Data\aspnet-MvcApplication1-20140319094015.mdf" failed with the operating system error 2(系统找不到指定的文件。). CREATE DATABASE failed. Some file names listed could not be created. Check related errors.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +392 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +815 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4515 System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) +1390 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +538 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +290 System.Data.SqlClient.<>c__DisplayClassa.<DbCreateDatabase>b__7(SqlConnection conn) +164 System.Data.SqlClient.SqlProviderServices.UsingConnection(SqlConnection sqlConnection, Action`1 act) +146 System.Data.SqlClient.SqlProviderServices.UsingMasterConnection(SqlConnection sqlConnection, Action`1 act) +3778055 System.Data.SqlClient.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +297 System.Data.Objects.ObjectContext.CreateDatabase() +260 MvcApplication1.Filters.SimpleMembershipInitializer..ctor() in d:\项目文档\MvcApplication1\MvcApplication1\Filters\InitializeSimpleMembershipAttribute.cs:37 [InvalidOperationException: 无法初始化 ASP.NET Simple Membership 数据库。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=256588] MvcApplication1.Filters.SimpleMembershipInitializer..ctor() in d:\项目文档\MvcApplication1\MvcApplication1\Filters\InitializeSimpleMembershipAttribute.cs:45 [TargetInvocationException: 调用的目标发生了异常。]

 这个数据文件在服务器上不存在的,在服务器配置的只有 bin  Content Images Scripts Views Global.asax Web.Config  这些文件

支持(0) 反对(0) 情义之印 | 园豆:15 (初学一级) | 2014-03-19 11:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册