Athos
Friday, February 18, 2005
 
Microsoft vs. Google: War!
天哪,我看到了什么…… 
 
在msn的首页: 
 
Search: Web/News/Image/Desktop……这不是正是Google的服务吗,尤其Google Desktop搜索本机文件……可以预见,对office系列文件,Microsoft将做得更好 
 
Msn Spaces……这不正是Google的Picasa和Hello所提供的照片共享服务吗? 
 
其它的还有Images…… 
 
继netscape之后,微软在网络领域似乎又开始了一场战争
Thursday, February 17, 2005
 
ASP.NET直接下载一个文件,而不是在IE中打开它
有的时候我们不想让用户直接在IE中打开已知类型的文件,比如Word,而希望能直接下载,这时候可用下面代码来替换Response.Redirect 
 
Response.ContentType = "application/octet-stream"; 
Response.AddHeader("Content-Disposition", "attachment;FileName="+YourFileName); 
Response.BinaryWrite((byte[])YourFileData.Rows[0]["AttachmentContent"]); 
Response.End(); 
 
 
补充一下。通常我喜欢把链接做成这样:  
 
<a href="download.aspx/hello.chm?fileid=12345">hello.chm</a>  
 
这样客户端下载的时候默认是 hello.chm 这个名字的。 from
Wednesday, February 16, 2005
 
xmlHttp的get/post方式及相应Browser/Server端的处理
用xmlhttp控件,可以以get或者post方式向server请求页面。"Implement Script Callback Framework in ASP.NET 1.x"中,Elvin Cheng是这样写client side的javascript代码的:

if (pageUrl.length + postData.length + 1 > 2067)
{
xmlRequest.open("POST", pageUrl, false);
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlRequest.send(postData);
}
else
{
if (pageUrl.indexOf("?") != -1)
xmlRequest.open("GET", pageUrl + "&" + postData, false);
else
xmlRequest.open("GET", pageUrl + "?" + postData, false);
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlRequest.send();
}

【Server Side】
一、
以get方式,信息只能通过Query String传递,server端获取是简单的,从Request.QueryString里可以得到所有的Key和Value。

二、
以post,则稍稍复杂。

二之甲、如果post一个String(例如Query String太长的时候),那很简单,Request.Form就类似get方式中的Request.QueryString;

二之乙、如果post一个xml对象,那么需要:

'Check that something has been posted
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then

'Check that an XMLHTTP object has been posted
If Request.ServerVariables("CONTENT_TYPE") <> "application/x-www-form-urlencoded" Then

'initialise an XML DOM object
Set oXMLDOM = Server.CreateObject("MSXML2.DOMDocument")
oXMLDOM.resolveExternals=False
oXMLDOM.validateOnParse=False
oXMLDOM.async=False

'load the request data into XML DOM
Call oXMLDOM.load(Request)

'Do something with XML DOM here
'***************************

End If
End If




相关msdn链接

http://support.microsoft.com/kb/290591/EN-US/
How To Submit Form Data by Using XMLHTTP or ServerXMLHTTP Object

http://support.microsoft.com/kb/290761/EN-US/
Frequently asked questions about ServerXMLHTTP
Monday, February 14, 2005
 
One more Javascript trick
var a={xml:contextXml.xml,menuId:reqMenuId};

Yeah that's it, looks weird huh, the result is "a" will be an Object, while

a[xml]=contextXml;
a[menuId]=reqMenuId;

-- learnt this from my.msn.com code

Powered by Blogger