在Arvixe主機(jī)部署ASP.net程序,web.config寫法-創(chuàng)新互聯(lián)

Arvixe主機(jī)是看不到 c盤或d盤的, 所有操作都是通過 Control Panel ,地址是在Arvixe主機(jī)部署ASP.n
et程序,web.config寫法

Address:
http://cp.meijinaiwo.com
Alternate Address:

成都創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)、鎮(zhèn)坪網(wǎng)絡(luò)推廣、小程序開發(fā)、鎮(zhèn)坪網(wǎng)絡(luò)營銷、鎮(zhèn)坪企業(yè)策劃、鎮(zhèn)坪品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們大的嘉獎;成都創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供鎮(zhèn)坪建站搭建服務(wù),24小時服務(wù)熱線:18982081108,官方網(wǎng)址:muchs.cn

http://cp.dock.arvixe.com
Alternate Address (HTTPS):

https://cpdock.arvixe.com
Username:
Password:

--------------------------------------------------

Add web site 以后, 系統(tǒng)會自動生成一個 web.config 在新網(wǎng)站的目錄下 , 不能用開發(fā)環(huán)境的 web.config替換這個文件,只能改寫它, 比較關(guān)鍵的是 connectionString的設(shè)置,經(jīng)多次嘗試,發(fā)現(xiàn)正確的方法是:

先建立數(shù)據(jù)庫 和 用戶

1 : 最初是 web.config 是這個樣子的:

<?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 : 如果要改首頁 , 可以這樣做:

<?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ù)庫名字,User ID 和 Password 是 建的用戶名和密碼

注意不能寫成
Integrated Security=True  , 然后不帶用戶名密碼
同時 , 為了配合這種寫法 , 在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的寫法不配套, 也就無法連接了。 (DBConnection 是 setting 的一個自建屬性名字)

如果一定要按照這種寫法, 那 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>

但是這樣的寫法在 arvixe主機(jī)上是報錯的,不知道什么原因,似乎是不認(rèn) 這個關(guān)鍵字: applicationSettings。

標(biāo)題名稱:在Arvixe主機(jī)部署ASP.net程序,web.config寫法-創(chuàng)新互聯(lián)
文章URL:http://muchs.cn/article18/deisdp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站網(wǎng)站營銷、外貿(mào)網(wǎng)站建設(shè)網(wǎng)站策劃、域名注冊、網(wǎng)站設(shè)計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)