2017-07-13 24 views
0

私のMVCプロジェクトはVS2015(LocalDB + IISexpress)でもうまくいきますが、このプロジェクトではEntityFrameworkも使用しています。IISにMVCプロジェクトを展開した後に500(内部サーバーエラー)

目標:。は今、私は地元のIISに公開してみたい(ver.10) それから私は、2016年 のMicrosoft SQL Management Studioでデータベースを添付私はIISでプロジェクトを追加しました。

問題: APIコントローラを呼び出すと、500エラーが返されます。

{"Message":"An error has occurred.","ExceptionMessage":"The underlying provider failed on ConnectionString.","ExceptionType":"System.Data.Entity.Core.EntityException","StackTrace":" at System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) 
    at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) 
    at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) 
    at System.Data.Entity.Internal.LazyInternalConnection.Initialize() 
    at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() 
    at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() 
    at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) 
    at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() 
    at System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() 
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) 
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) 
    at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) 
    at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer) 
    at Newtonsoft.Json.JsonConvert.SerializeObject(Object value) 
    at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) 
    at WebApplication1.Controllers.BaseAPIController.ToJSON(Object obj) 
    at lambda_method(Closure , Object , Object[]) 
    at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) 
    at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"The given path's format is not supported.","ExceptionType":"System.NotSupportedException","StackTrace":" at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath) 
    at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath) 
    at System.IO.Path.GetFullPath(String path) 
    at System.Data.Common.ADP.GetFullPath(String filename) 
    at System.Data.Common.DbConnectionOptions.ExpandDataDirectory(String keyword, String value, String& datadir) 
    at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) 
    at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) 
    at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) 
    at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) 
    at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) 
    at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) 
    at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.SetConnectionString(DbConnection connection, DbConnectionPropertyInterceptionContext`1 interceptionContext) 
    at System.Data.Entity.Core.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)"}} 

web.configファイルで私の接続文字列は次のとおりです。

"接続文字列" の設定、デプロイ後の接続文字列は次のようになりますでIISで
<connectionStrings> 
<add name="UserDBEntities" connectionString="metadata=res://*/UserDbEntities.csdl|res://*/UserDbEntities.ssdl|res://*/UserDbEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\UserDB.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
</connectionStrings> 

metadata=res://*/UserDbEntities.csdl|res://*/UserDbEntities.ssdl|res://*/UserDbEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\UserDB.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" 

私が変更唯一のソースからソース=(LocalDB)\ MSSQLLocalDBソース= DesktopName \ MSSQLSERVER2016

+1

'「ExceptionMessageを」:「基になるプロバイダーはのConnectionStringに失敗しました。」、」 ExceptionType ":" System.Data.Entity.Core.EntityException "...'あなたの投稿を** ** **メッセージ全体で更新してください。 – mjwills

+0

エラーメッセージを更新しました。 –

答えて

0

Visual Studioでデータベースを開くことができる場合は、SQL Serverオブジェクトエクスプローラーウィンドウでデータベースを右クリックし、[プロパティ]を選択します。プロパティペインには、接続文字列のある行があります。

そうでない場合は、手動で接続文字列を構築する必要があります、SQL Serverの、おそらくのようなものになります。

Data Source=[host];Initial Catalog=[DB];Integrated Security=False;User Id=[user];Password=[password];MultipleActiveResultSets=True 
+0

私はこの接続文字列をIISのデータソース= DESKTOP-Name \ MSSQLSERVER2016; AttachDbFilename = C:\ Projects \ Anger-cli-mvc \ Angle-cli-mvc \ WebApplication1 \ App_Data \ UserDB.mdf;に統合しようとしました。セキュリティ= True; MultipleActiveResultSets = True;アプリケーション名= EntityFramework'ですが、エラーは「キーワードがサポートされていません」に変更されます」「{"メッセージ": "エラーが発生しました"、 "ExceptionMessage": "サポートされていないキーワード:ソース "、" ExceptionType ":" System.ArgumentException "、" StackTrace ":...' –

関連する問題