2009年8月31日 星期一

局部設定responseEncoding

通常我們會因為整個系統中要使用的編碼會設定在web.config中,

但是有時會因為與其他系統的介接需要做response,而對方的系統只吃big5時可以單支指定
context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("big5");


context.Response.HeaderEncoding = System.Text.Encoding.GetEncoding("big5");
context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("big5");
context.Response.AppendHeader("Content-Disposition", "attachment;filename=big5");

來做局部設定

2009年8月27日 星期四

如何查看w3wp.exe是在執行那個站台

1.在cmd下打Iisapp 即會顯示目前在運作的 w3wp.exe 所屬的 PID 及對應的集區,
集區會因為還沒回收等...會有重複,但可透過PID來對應工作管理員的處理程序。
如:
W3WP.exe PID: 5716 AppPoolid:eCampus3P
W3WP.exe PID: 5710 AppPoolid:eCampus3
2.再開啟工作管理員=>檢視=>選擇欄位=>勾選PID即可得知目前正在執行的w3wp.exe是在執行那個站台,可由應用集區來做區分,再依佔用的資源量判斷是否需要再做調整

參考資料:
Iisapp.vbs:IIS 應用程式查詢指令檔

2009年8月26日 星期三

windows7的IIS管理員放在那裡

要顯示系統管理工具,在下方工具列空白處點選滑鼠右鍵,選內容
在開始功能表,點選自訂
找到系統管理工具,選擇顯示所有程式功能表
在開始->程式集中就會看到系統管理工具
參考資料:
WINDOWS7預設是不安裝IIS7的

2009年8月17日 星期一

取固定長度的顯示字串

///
/// 取固定長度的顯示字串
///

/// 原始字串
/// 最大長度
///
public string ShowString(string strOri, int iMax)
{
string strResult;
int n;

strResult = "";
n = 0;

for (int i = 0; i < strOri.Length; i++)
{
char ch = strOri[i];

if (ch >= 'a' && ch <= 'z')
{
n += 1;
}
else if (ch >= 'A' && ch <= 'Z')
{
n += 2;
}
else
n += 3;

if (n >= (iMax - 2) * 3)
break;

strResult += strOri[i];
}

if (strResult.Length < strOri.Length)
strResult += "...";
return strResult;

}