2017-07-28 54 views
-1

我一直在搜索解決我的問題的各種搜索源。我已經發布了IIS上的一個網站,我一直在努力,這是我第一次發佈的網站上IIS。發佈時連接到DB.mdf時出錯IIS

我似乎無法連接到數據庫。

我會提供我已經在這裏做降權的一切..

欣賞任何幫助,請....

web.config文件中發佈的網站目錄C:\FinancialHubTest。從cmd在

MSSQLLocalDB

applicationHost文件​​ 在一個側面說明我也試過在我web.config文件中添加User Instance=True我的連接字符串,但它不工作..

<connectionStrings> 
    <!--<add name="ConnStr" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFileName=|DataDirectory|\FinancialHub.mdf;Integrated Security=True" />--> 
    <add name="ConnStr" 
     connectionString="Data Source=(LocalDB)\.\IIS_DB;Integrated Security=True;" /> 
</connectionStrings> 

詳細用Notepad2編輯的C:\ Windows \ System32 \ inetsrv \ config。 我在IIS中使用FinancialHub作爲我applicationPool我發佈的網站

<applicationPools> 
     <add name="DefaultAppPool" managedRuntimeVersion="v4.0" /> 
     <add name="Classic .NET AppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" /> 
     <add name=".NET v2.0 Classic" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" /> 
     <add name=".NET v2.0" managedRuntimeVersion="v2.0" /> 
     <add name=".NET v4.5 Classic" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" /> 
     <add name=".NET v4.5" managedRuntimeVersion="v4.0" /> 
     <add name="FinancialHub" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated"> 
      <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" /> 
     </add> 
     <applicationPoolDefaults managedRuntimeVersion="v4.0"> 
      <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="false" /> 
     </applicationPoolDefaults> 
    </applicationPools> 

與程序App_Data具有FinancialHub.mdf文件

mdf

我的SQL Server對象資源管理器我發佈的網站目錄,只有當我通過Visual Studio 2015運行我的網站時出現連接我認爲這將運行在IIS Express上。

sql

我每次在這裏和那裏改變時都會收到這個錯誤,但我真的很確定爲什麼。或者我對web.config等進行了哪些更改會導致此錯誤。我也檢查Windows事件日誌。

errorsql

我也跟着上處理這一問題這2個鏈接,

Using LocalDB with Full IIS, Part 1: User Profile

Using LocalDB with Full IIS, Part 2: Instance Ownership

如果需要更多的信息,我可以提供..

我覺得我一直在圍繞布什試圖弄清楚但我似乎無法解決它..

我真的很感激任何幫助請。非常感謝。

+1

請勿*上傳*圖片*的代碼。我們無法對此做任何事情,任何試圖幫助您的人都必須重新輸入所有內容。它把你的汽車照片給機修工並讓他們告訴你什麼是錯的。 – Siyual

+0

Siyual你碰巧解決了我的問題嗎?感謝您的編輯@marc_s – domster

回答

1

即使在將應用程序發佈到IIS之後,您仍在使用LocalDB。 LocalDB (App_Data中的SQL數據庫)主要僅用於開發和測試目的。

當您在IIS上託管該站點時,您需要一個真正的SQL Server。因此,您需要將SQL Server安裝在託管應用程序的相同服務器或專用SQL服務器中。然後將現有數據庫附加或複製到SQL Server。

+0

所以我必須在我的連接字符串中使用這樣的東西?數據源=。\ SQLEXPRESS;初始目錄= OldFashionedDB;集成安全性=真我可以知道是否有任何指導我可以遵循? – domster

+0

SQLExpress適合測試。您將需要更新指向SQLExpress的連接字符串。 – Win

+0

無法使用MSSQLLocalDB在本地託管網站上運行App_Data? – domster