雪美·考拉
傲雪之美,考拉之憨。
博客园
首页
新随笔
联系
订阅
管理
随笔 - 144 文章 - 1 评论 - 522 trackbacks - 9
<
2006年2月
>
日
一
二
三
四
五
六
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
10
11
昵称:
雪美·考拉
园龄:
7年7个月
粉丝:
2
关注:
0
搜索
常用链接
我的随笔
我的评论
我的参与
最新评论
我的标签
我的标签
WebMatrix
(10)
随笔分类
.Net(34)
Ajax(4)
DataBase(5)
Visual Basic(8)
Visual C++(1)
WebMatrix(12)
WEB开发(31)
不用墨水的作品(9)
杂谈(38)
随笔档案
2012年1月 (12)
2009年10月 (1)
2009年3月 (4)
2009年2月 (4)
2008年2月 (2)
2007年9月 (1)
2007年8月 (2)
2007年6月 (1)
2006年9月 (8)
2006年8月 (1)
2006年7月 (1)
2006年5月 (3)
2006年4月 (2)
2006年3月 (2)
2006年2月 (3)
2006年1月 (1)
2005年12月 (2)
2005年9月 (1)
2005年8月 (4)
2005年7月 (3)
2005年6月 (1)
2005年5月 (10)
2005年4月 (2)
2005年3月 (1)
2005年2月 (5)
2005年1月 (2)
2004年12月 (5)
2004年10月 (2)
2004年9月 (2)
2004年8月 (20)
2004年7月 (16)
2004年6月 (21)
相册
天津程序员[聚]照
博客链接
ceocio
Realize .NET Potential
ScottGu's Blog
ScottGu博客中文版
Think Different and Think More
宝玉
蝈蝈俊
孔曰成仁,孟曰取E
灵感之源
迷失网络
木野狐的 Web Log
思归呓语
技术站点
Ajaxian
C# Corner
CodeGuru
CSS Reboot
DotNetJunkies
Got Dot Net
JavaScript Kit
MVPs.org
Planet Source Code
Regular Expression Library
TechNet 中文站点
The Code Project
The Programmer's File Format Collection
TheServerSide.NET
TopXML
vbAccelerator.com
VC学习教程
VC知识库
W3schools
WebFX
动网新闻系统 → 技术文章
符合W3C标准的CSS布局站点集
孟宪会之精彩世界
面向Mozilla开发
社区推荐
ASP.NET Forums
ASP.NET Forums
Code Comments
CSDN社区
kbAlertz!
Microsoft Search Engine for Microsoft Server Content
Sourceforge.net
博客堂
微软中国社区
问专家
积分与排名
积分 - 199577
排名 - 428
最新评论
阅读排行榜
评论排行榜
推荐排行榜
2006年2月8日
让MagicAjax支持中文!
过年啦,回到家一直不能上网,很是一个郁闷,不过大年廿九晚上闲来无事,终于解决了MagicAjax中文乱码的问题。
自从MA 0.2.x发行以来都不能支持JS的中文,比如把JS脚本中的那个"Loading ..."换成"数据加载中 ..."后,再运行时出现的那个条就是乱码。如果更改编码格式页面又会乱掉。
哈哈,下载MA的源代码包,打开MagicAjaxModule.cs文件,看到
protected
void
Application_BeginRequest(
object
sender, EventArgs e)
{
HttpContext context
=
((HttpApplication)sender).Context;
//
Init private fields
_threadAbortExceptionThrown
=
false
;
_request
=
context.Request;
_response
=
context.Response;
//
Create a new context and add it to the items collection for later retrieval
//
by MagicAjaxContext.Current
_magicAjaxContext
=
new
MagicAjaxContext();
HttpContext.Current.Items.Add(MagicAjaxContext.ContextKey, _magicAjaxContext);
//
Check if the request is for the embedded AjaxCallObject.js script
if
(context.Request.RawUrl.EndsWith(
"
AjaxCallObject.js.aspx
"
))
{
context.Response.ContentType
=
"
text/javascript
"
;
object
cachedAjaxCallObjectJs
=
context.Cache[
"
__CACHED_AJAXCALLOBJECT_JS
"
];
if
(cachedAjaxCallObjectJs
==
null
)
{
//
read and output the embedded AjaxCallObject.js file from the manifest
using
(System.IO.StreamReader reader
=
new
System.IO.StreamReader(
typeof
(MagicAjaxModule).Assembly.GetManifestResourceStream(
"
MagicAjax.script.AjaxCallObject.js
"
)))
{
cachedAjaxCallObjectJs
=
reader.ReadToEnd();
}
context.Cache.Insert(
"
__CACHED_AJAXCALLOBJECT_JS
"
, cachedAjaxCallObjectJs);
}
context.Response.Write(cachedAjaxCallObjectJs);
context.Response.Cache.SetExpires(DateTime.Now.AddYears(
1
));
context.Response.End();
}
}
噢,这样呀,让它支持GB2312不就行了。
protected
void
Application_BeginRequest(
object
sender, EventArgs e)
{
HttpContext context
=
((HttpApplication)sender).Context;
//
Init private fields
_threadAbortExceptionThrown
=
false
;
_request
=
context.Request;
_response
=
context.Response;
_response.ContentEncoding
=
System.Text.Encoding.GetEncoding(
"
GB2312
"
);
//
Create a new context and add it to the items collection for later retrieval
//
by MagicAjaxContext.Current
_magicAjaxContext
=
new
MagicAjaxContext();
HttpContext.Current.Items.Add(MagicAjaxContext.ContextKey, _magicAjaxContext);
//
Check if the request is for the embedded AjaxCallObject.js script
if
(context.Request.RawUrl.EndsWith(
"
AjaxCallObject.js.aspx
"
))
...
加入了_response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
编译Release文件,然后再使用这个新的DLL就OK了。
不知道,还有没有别的办法,或是以上方法都什么不当之处。
[仅就解决MA支持中文的问题]
posted @ 2006-02-08 12:15 雪美·考拉 阅读(3241) 评论(17)
编辑