国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

IDesign C#編碼規范(之六)

2024-07-21 02:18:49
字體:
來源:轉載
供稿:網友


大家中秋好,首先非常感謝xiaxia翻譯的資料。
由于我對這個文檔也是興趣濃厚,所以就把下面的部分給翻譯了。
希望大家多多指教。


4.2asp.net and web services
1.避免將代碼放入asp.net的aspx文件中。 所有的代碼都應該放在相關代碼的partial類中。
avoid putting code in aspx files of asp.net. all code should be in the code beside partial class.
2.放在相關代碼的partial類中的代碼,應該調用其他組件,而不是用于寫直接的業務邏輯。
code in code beside partial class of asp.net should call other components rather than contain direct business logic.
3.訪問線程變量之前應該檢查其是否為null。
always check a session variable for null before accessing it.
4.在事務頁面或web頁面,要將線程存儲在sql server中。
in transactional pages or web services, always store session in sql server.
5.在asp.net中,避免將服務器控件的auto-postback屬性設置為true.
avoid setting to true the auto-postback property of server controls in asp.net
6.對于asp.net頁面,運用智能瀏覽。
turn on smart navigation for asp.net pages.
7.盡量為web服務提供接口。
strive to provide interfaces for web services.
a) see appendix a of programming .net components.
8.總是為web服務提供命名空間和服務描述。
always provide namespace and service description for web services.
9.總是為web方法提供描述。
always provide a description for web methods.
10. 當加入web服務引用時,應該給與有意義的命名。
when adding a web service reference, provide meaningful name for the location.
11. 在asp.net頁面和web服務頁面,要在局部屬性里加入線程變量。只有可以訪問線程變量的屬性和其余使用屬性的代碼,不是線程變量。
in both asp.net pages and web services, wrap a session variables in a local property.
only that property is allowed to access the session variable, and the rest of the code uses the property, not the session variable.
public class calculator: webservice
{
int memory
{
get
{
int memory = 0;
object state = session[“memory”];
if(state != null)
{
memory = (int)state;
}
}
return memory;
set
{
session[“memory”] = value;
}
}
[webmethod(enablesession = true)]
public void memoryreset()
{
memory = 0;
}
}
12. 總是修改客戶web服務包裝類使其支持cookies.
always modify client-side web service wrapper class to support cookies.
a)當你無法知道服務是否服務所用線程的狀態時。
you have no way of knowing whether the service uses session state or not.
public class calculator: soaphttpclientprotocol
{
public calculatorex()
{
cookiecontainer = new system.net.cookiecontainer();
url = “http://...”;
}
}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 开封县| 赣州市| 洛南县| 定州市| 水富县| 阿巴嘎旗| 安仁县| 方山县| 民权县| 太白县| 营山县| 曲沃县| 收藏| 吐鲁番市| 通城县| 江达县| 岑溪市| 柳江县| 金沙县| 湘阴县| 井研县| 肇东市| 苗栗县| 廉江市| 大城县| 禄丰县| 八宿县| 灵寿县| 蒲江县| 延寿县| 平谷区| 高台县| 陕西省| 桃园县| 互助| 磐石市| 霍城县| 富裕县| 尼玛县| 武乡县| 肃北|