標籤:style http color 使用 strong 檔案
筆者想使用ASP.NET Web 應用程式管理工具來添加身分識別驗證。
點擊項目->asp.net配置開啟了ASP.Net網站管理工具頁面:
然後點擊security選項卡,出現如下問題:
There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.
The following message may help in diagnosing the problem: Unable to connect to SQL Server database.
筆者用的編程環境是VS2012。
解決方案:
詳細介紹參考《asp.NET 2.0中的登陸控制項簡介 》
其中文中提及到的asp.net Web Site Administration Tool中Security需要一些相關的設定才可以應用,具體設定方法如下:
(Microsoft MSDN:http://forums.microsoft.com/msdn/showpost.aspx?postid=81990&siteid=1&PageID=0
)
在你的SQL伺服器上建立asp.NET 2.0的應用程式支援資料,需要建立一些表,預設是放在aspnetdb的資料庫裡面。而安裝時並沒有產生aspnetdb資料庫所以出錯。
首先,運行 aspnet_regsql(C:\windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe) 來安裝membership所要建立的資料庫。
在嚮導中選擇SQL驗證,輸入資料庫的使用者名稱、密碼(以前建的)。
然後,修改機器上web.config檔案(C:\windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config)或者是工程的web.config檔案。
要注意<connectionStrings> ... </connectionStrings>這個節
在本工程web.config中添加如下語句:
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer"
connectionString="Data Source=THINK-PC;Initial Catalog=aspnetdb;Persist Security Info=True;User ID=sa;Password=123456"
providerName="System.Data.SqlClient" />
</connectionStrings>
成功!