簡體   English   中英

我如何解決此錯誤,MVC 4 中 asp.net 的 web.config 中不允許使用“connectionStringName”屬性

[英]How can i resolve this error the 'connectionStringName' attribute is not allowed in web.config of asp.net in MVC 4

我如何解決 mvc 4 asp.net 中的 Visual Studio 中不允許 connectionStringName' 屬性的問題

web.config

在此處輸入圖片說明

<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-MVE-20171019175539;Integrated Security=SSPI" />
<add name="SchoolContext"    connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\university.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>

Web.config // Line 60 column 189 the code below

    <providers>
    <add name="DefaultSessionProvider" 
    type="System.Web.Providers.DefaultSessionStateProvider, 
    System.Web.Providers, Version=1.0.0.0, Culture=neutral, 
    PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
    </providers>

移除:

<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-MVE-20171019175539;Integrated Security=SSPI" />

從您的連接字符串。 您不需要它,因為您使用的是“SchoolContext”。

也刪除:

<providers>
<add name="DefaultSessionProvider" 
type="System.Web.Providers.DefaultSessionStateProvider, 
System.Web.Providers, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>

您沒有使用任何類型的身份驗證,是嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM