在前面文章ExtJs與WCF之間的跨域訪問已經通過服務端代理的方式解決了ExtJs與WCF跨域訪問的問題
第一步
[WebInvoke(Method =
UriTemplate =
public Stream GetProductsByPageCorssDomain(int start
{
ProductsDataContext productDbContext = new ProductsDataContext();
IQueryable<Product> res = productDbContext
PageData<Product[]> returnData = new PageData<Product[]>();
returnData
res = res
res = res
returnData
System
MemoryStream ms = new MemoryStream();
formater
ms
StreamReader sr = new StreamReader(ms);
string objContent = sr
string returnStr = callback+
sr
ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);
sw
sw
ms
WebOperationContext
return ms;
}
第二步
<html xmlns=
<head>
<title>ExtJs+WCF+LINQ打造分頁Grid</title>
<link rel=
<script type=
<script type=
<link rel=
<script type=
<script type=
</head>
<body>
<h
ExtJs+WCF+LINQ打造分頁跨域Grid</h
<div id=
</div>
</body>
</html>
第三步
/*
* Ext JS Library
* Copyright(c)
*
*
*
*/
Ext
var proxy = new Ext
url:
});
var reader = new Ext
{root:
[
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
{name:
]
);
var store = new Ext
{proxy:proxy
);
// create the Grid
var grid = new Ext
store: store
columns: [
{id:
{header:
{header:
{header:
{header:
{header:
{header:
]
stripeRows: true
autoExpandColumn:
height:
width:
title:
viewConfig:
{
columnsText:
sortAscText:
sortDescText:
}
bbar: new Ext
pageSize:
store: store
displayInfo: true
displayMsg:
emptyMsg:
})
});
grid
//載入
store
grid
});
接下來
兩種方案對比
第一種方案要通過服務端WebClient訪問WCF服務
上面兩點都是說明第一種方案的缺點
From:http://tw.wingwit.com/Article/program/ASP/201311/21689.html