<system.web>
<httpRuntime requestValidationMode="2.0" />
<pages validateRequest="false" />
</system.web>
後者比較算是正解 基本上處理掉 <script 我想 XSS 就解決一大半
Imports System.Runtime.CompilerServices Imports Microsoft.VisualBasic Public Module DateTimeExtension ''' <summary> ''' 將系統時間轉為當地的時間並轉為字串 ''' </summary> ''' <param name="dtSystem"></param> ''' <returns></returns> ''' <remarks></remarks> <Extension()> _ Public Function ToCountryDateTimeString(ByVal dtSystem As DateTime) As String If dtSystem = DateTime.MinValue Then Return "n/a" End If Dim cstTime As DateTime = dtSystem.ToCountryDateTime() ' tr-TR -> dd.MM.yyyy HH:mm:ss Dim langCode As String = SHOPUNT.DB.SysConfig.GetSysConfig("DefaultLangCode") Dim culture As New System.Globalization.CultureInfo(langCode) If cstTime.AddMonths(6) < Now Then Return cstTime.ToString("dd.MM.yyyy HH:mm", culture) Else Return cstTime.ToString("dd.MMM HH:mm", culture) End If End Function ''' <summary> ''' 將系統時間轉為當地的時間 ''' </summary> ''' <param name="dtSystem"></param> ''' <returns></returns> ''' <remarks></remarks> <Extension()> _ Public Function ToCountryDateTime(ByVal dtSystem As DateTime) As DateTime Dim cstZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(SHOPUNT.DB.SysConfig.GetSysConfig("DefaultTimeZone")) Dim localZone As TimeZoneInfo = TimeZoneInfo.Local Dim cstTime As DateTime = TimeZoneInfo.ConvertTime(dtSystem, localZone, cstZone) Return cstTime End Function ''' <summary> ''' 將使用者輸入的時間轉為系統時間 ''' </summary> ''' <param name="dtCountry"></param> ''' <returns></returns> ''' <remarks></remarks> <Extension()> _ Public Function ToSystemDateTime(ByVal dtCountry As DateTime) As DateTime Dim cstZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(SHOPUNT.DB.SysConfig.GetSysConfig("DefaultTimeZone")) Dim localZone As TimeZoneInfo = TimeZoneInfo.Local Dim sysTime As DateTime = TimeZoneInfo.ConvertTime(dtCountry, cstZone, localZone) Return sysTime End Function End Module使用上 只要
List<DB.Member> listOfMember = new List<DB.Member>()
{ new DB.Member(15), new DB.Member(20), new DB.Member(25), new DB.Member(30) };
// Exists: 單純看有無符合條件的資料
bool IsMemberExists = listOfMember.Exists(x => x.Email == "darren@acaciaco.com");
// FindIndex: 找出第一個符合條件的 index,找不到傳回 -1
int index = listOfMember.FindIndex(x => x.Email == "darren@acaciaco.com");
// Find: return 第一個符合條件的object, 找不到傳回 null
DB.Member objMember = listOfMember.Find(x => x.Email.Contains("acaciaco.com"));
// FindAll: return 所有符合條件的objects
List<DB.Member> listOfMember2 = listOfMember.FindAll(x => x.Email.Contains("acaciaco.com"));
Dim listOfMember As New List(Of DB.Member)() From { _
New DB.Member(15), New DB.Member(20), New DB.Member(25), New DB.Member(30) }
' Exists: 單純看有無符合條件的資料
Dim IsMemberExists As Boolean = listOfMember.Exists(Function(x) x.Email = "darren@acaciaco.com")
' FindIndex: 找出第一個符合條件的 index,找不到傳回 -1
Dim index As Integer = listOfMember.FindIndex(Function(x) x.Email = "darren@acaciaco.com")
' Find: return 第一個符合條件的object, 找不到傳回 Nothing
Dim objMember As DB.Member = listOfMember.Find(Function(x) x.Email.Contains("acaciaco.com"))
' FindAll: return 所有符合條件的objects
Dim listOfMember2 As List(Of DB.Member) = listOfMember.FindAll(Function(x) x.Email.Contains("acaciaco.com"))
DDR("ExpirationDays") = DBNull.Value
For I As Int32 = 1 To DT.Rows.Count
If order_num_right = DT.Rows(I - 1)("Pid") Then
Pid_No = I - 1
End If
#OFCL.Pid = DT.Rows(I - 1)("Pid")
#OFCL.GetDataRowAndReturnSelfOrNothing()
Dim NewT As String = oT.Result
NewT = NewT.Replace("#Y#", StartY + (I - 1) * LH)
NewT = NewT.Replace("#序號#", I.ToString)
NewT = NewT.Replace("#品號#", OFCL.Pid)
NewT = NewT.Replace("#品名#", OFCL.Product_Name)
NewT = NewT.Replace("#包裝#", OFCL.Package)
NewT = NewT.Replace("#單位#", OFCL.UNIT)
NewT = NewT.Replace("#數量#", OFCL.Qty)
NewT = NewT.Replace("#箱數#", OFCL.BOX)
NewT = NewT.Replace("#總數量#", OFCL.Total)
NewT = NewT.Replace("#未稅價#", OFCL.Price)
NewT = NewT.Replace("#總金額#", OFCL.Sum)
Res &= NewT
Next