Address:
http://cp.meijinaiwo.com
Alternate Address:
http://cp.dock.arvixe.com
Alternate
Address (HTTPS):
https://cpdock.arvixe.com
Username:
Password:
--------------------------------------------------
Add web site 以后, 系統(tǒng)會(huì)自動(dòng)生成一個(gè) web.config 在新網(wǎng)站的目錄下 , 不能用開(kāi)發(fā)環(huán)境的 web.config替換這個(gè)文件,只能改寫(xiě)它, 比較關(guān)鍵的是 connectionString的設(shè)置,經(jīng)多次嘗試,發(fā)現(xiàn)正確的方法是:
先建立數(shù)據(jù)庫(kù) 和 用戶
1 : 最初是 web.config 是這個(gè)樣子的:
<?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer> <directoryBrowseenabled="true" /> <defaultDocument> <files> <clear/> <addvalue="Default.aspx" /> <addvalue="index.php" /> <addvalue="Default.html" /> <addvalue="Default.htm" /> <addvalue="Default.asp" /> <addvalue="index.pl" /> <addvalue="Default.cshtml" /> <addvalue="index.htm" /> <addvalue="index.html" /> <addvalue="index.cshtml" /> </files> </defaultDocument> <httpProtocol> <customHeaders> <clear/> </customHeaders> </httpProtocol> </system.webServer></configuration>
2 : 如果要改首頁(yè) , 可以這樣做:
<?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer> <directoryBrowseenabled="true" /> <defaultDocument> <files> <clear/> <addvalue="aspMain.aspx" /> </files> </defaultDocument> <httpProtocol> <customHeaders> <clear/> </customHeaders> </httpProtocol> </system.webServer></configuration>
3 : connectionString的設(shè)置,加:
<?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer> <directoryBrowseenabled="true" /> <defaultDocument> <files> <clear/> <addvalue="aspMain.aspx" /> </files> </defaultDocument> <httpProtocol> <customHeaders> <clear/> </customHeaders> </httpProtocol> </system.webServer> <connectionStrings> <addname="ApplicationServices" connectionString="Data Source=localhost;Initial Catalog=databaseName; Integrated Security=false;User ID=username;Password=password" /> </connectionStrings></configuration>
Catalog 是 建的數(shù)據(jù)庫(kù)名字,User ID 和 Password 是 建的用戶名和密碼
注意不能寫(xiě)成
Integrated Security=True , 然后不帶用戶名密碼
同時(shí) , 為了配合這種寫(xiě)法 , 在asp程序中 , 取連接字符串 就應(yīng)該是這樣 :
string sConnection = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
注意 這里的 ApplicationServices 要和 web.config 里的 addname="ApplicationServices" 名字一樣
這樣就能連接成功了 。
-----------------------------
有人是把 connectionString 放到asp程序的setting里,然后在asp程序中 ,用
string sConnection = Properties.Settings.Default.DBConnection;
取連接字符串, 這樣就和web.config的寫(xiě)法不配套, 也就無(wú)法連接了。 (DBConnection 是 setting 的一個(gè)自建屬性名字)
如果一定要按照這種寫(xiě)法, 那 web.config 應(yīng)該是類似這樣:
<applicationSettings> <appName.Properties.Settings> <settingname="DBConnection" serializeAs="String"> <value>Data Source=localhost,1440;Initial Catalog=databaseName;User ID=username;Password=password</value> </setting> </appName.Properties.Settings></applicationSettings>
但是這樣的寫(xiě)法在 arvixe主機(jī)上是報(bào)錯(cuò)的,不知道什么原因,似乎是不認(rèn) 這個(gè)關(guān)鍵字: applicationSettings。
標(biāo)題名稱:在Arvixe主機(jī)部署ASP.net程序,web.config寫(xiě)法-創(chuàng)新互聯(lián)
文章URL:http://chinadenli.net/article18/deisdp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、網(wǎng)站營(yíng)銷、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站策劃、域名注冊(cè)、網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容