小新二三事 二三事 電視精/戲院 ASP .NET 新手工作日誌

2009年7月11日星期六

ASP.NET Warning: 具有潛在危險 Request.Form 的值已從用戶端偵測到

ASP.NET Warning: 具有潛在危險 Request.Form 的值已從用戶端偵測到

具有潛在危險 Request.Form 的值已從用戶端偵測到

若是出現這樣的錯誤訊息,代表頁面上有文字內容是包含Html這類的語法,通常在使用一些Html的編輯器(留言板、討論區之類常用)做資料送出的動作的時候會發生。

解決辦法如下:

在頁面的Page指示語加入 validateRequest="false"


http://blog.blueshop.com.tw/greenwings/archive/2007/02/22/49690.aspx

ASP.NET Warning: 並未將物件參考設定為物件的執行個體

ASP.NET Warning: 並未將物件參考設定為物件的執行個體

System.NullReferenceException:
並未將物件參考設定為物件的執行個體

通常...這種錯誤就是
"使用了某種物件, 但卻未宣告"
朝這個方向去找吧, 仔細檢查一下程式裡面有沒有哪裡有這樣的情形
該用new 沒有new

如果用的是vs.net2003...
那這個錯誤下中斷點,瞬間就能找出

2009年7月10日星期五

ASP.NET Code: SQL SELECT command based on DropDownList

ASP.NET Code: SQL SELECT command based on DropDownList

SQL SELECT command based on DropDownList

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
SelectCommand="SELECT * FROM [menu] WHERE (([region] = @region) AND ([lang] = @lang)) ORDER BY [menuId]"
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="region"
PropertyName="SelectedValue" Type="String" />
<asp:Parameter DefaultValue="1" Name="lang" Type="String" />
</SelectParameters>

ASP.NET Warning: Cannot insert explicit value for identity column in table 'Table' when IDENTITY_INSERT is set to OFF

ASP.NET Warning: Cannot insert explicit value for identity column in table 'Table' when IDENTITY_INSERT is set to OFF

Things to check

1. Set table id as (Is Identity) to Yes
1a. Set table id as (Primary Key)

2. Make a new SqlDataSource with INSERT command
Coz after you change table id, SqlDataSource will not be updated auto.

3. Check the INSERT command with original SqlDataSource
Should have difference

ASP.NET Code: Server.MapPath

ASP.NET Code: Server.MapPath

Dim PathName As String
Dim FileName As String
PathName = LangPath & "/collection" & cat & ".xml"
FileName = Server.MapPath(PathName)
http://fuchangmiao.blogspot.com/2008/11/aspnet-path.html

2009年7月9日星期四

XP IIS 5.1 + ASP.NET 3.5 setup

XP IIS 5.1 + ASP.NET 3.5 setup

http://www.mobile01.com/topicdetail.php?f=300&t=966120

1. download dotnetfx35.exe 197MB
http://go.microsoft.com/?linkid=7755937

2. reinstall IIS

3. run aspnet_regiis.exe -i

4. check ASP.NET runtime 2.0

5. open IE @ http://localhost/
確定連結裡的都沒問題
http://timstall.dotnetdevelopersjournal.com/resolving_http_500_server_errors_in_aspnet_and_iis_51.htm

主要是下列幾項
1. 用command line 到
C:\WINDOWS\Microsoft.NET\Framework\vv2.0.50727 目錄下執行
aspnet_regiis.exe -i

2. 然後確定你的虛擬目錄 使用 .net framework 2.0
到IIS管理介面
滑鼠右鍵 看你的虛擬目錄是否 使用2.0

3. 然後再看extension裡是否有允許
2.0的plugin

XP IIS 5.1 "拒絕存取路徑"的問題

XP IIS 5.1 "拒絕存取路徑"的問題

http://social.msdn.microsoft.com/Forums/zh-TW/236/thread/25ef53b6-656f-42b5-b0e7-0a61e6a8a45b

1. right click C:\Inetpub\wwwroot\WebSite1

2. 內容、安全性、新增使用者 ASPNET ,並授與 ASPNET 寫入權限。
你要把你要存放檔案的存取權限(修改與寫入權限)設定給 ASPNET 帳戶才可以。
錯誤訊息的內容就是在告訴你這件事。

從VS2005去執行(開始偵錯)的話就可以,
VS2005 有虛擬伺服器,假定你網頁專案開在虛擬伺服器上的話,不需要管到權限問題,若是你網頁專案直接開在 IIS 上或是執行實體網站時,就會碰上權限問題。 所以請用檔案總管,把 Session("Path") 的路徑用滑鼠右鍵,內容、安全性、新增使用者 ASPNET ,並授與 ASPNET 寫入權限。