asp.net responseдÎļþ
protected void Button2_Click(object sender, EventArgs e)
{
bool ok = true;
string fileName;
fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc";
try
{
Response.ClearHeaders();
Response.ContentType = "application/msword;";
Response.Charset = "UTF-8";
Response.AddHeader("Content-Disposition", string.Format("attachment;filename=\"{0}\"", fileName));
Response.BinaryWrite(Encoding.Default.GetBytes(strr));
}
catch (Exception ex)
{
ok = false;
Response.Write("Éú³ÉÎļþʧ°Ü£º" + ex.Message + "£¬ÇëÉÔºóÔÙÊÔ¡£");
CreateGbpt(fileName, strr);
}
if (ok)
{
Response.End();
}
}
private void CreateFile(string fileName, string text)
{
bool ok = true;
string filePath;
&
Ïà¹ØÎĵµ£º
Ò».ÕªÒª
¡¡¡¡ºÍ×ÔÉíˮƽÓйØ, ÎÒ×Üϲ»¶Ð´ÈëÃż¶±ðµÄÎÄÕÂ.±ÈÈçËäÈ»×öÏîÄ¿ÓùýÒ»¸öÄÚ²¿µÄMVC¿ò¼Ü, µ«Êǵ±¿´µ½ASP.NET MVCʱÎÒÈ´»¹ÊDz»ÖªµÀ´ÓÄÄÀïÈëÊÖ¿ªÊ¼Ñ§Ï°µÄºÃ.ÓÚÊÇÎÒдÏÂÕâÆªÈëÃż¶µÄϵÁÐÎÄÕÂ,¡¡ ½«ÀÏÕÔ(Jeffrey Zhao)µÄASP.NET MVCϵÁÐÊÓÆµ¿Î³Ìѧµ½µÄ֪ʶÔÙÀí½âºÍÔÙÏû»¯, ÈÃ×µÄÈËÒ²Äܸú×ÅÎÒѧ¶®ASP.NET MVC
¡¡¡¡¶þ. ......
±¾Ö÷Ìâ½éÉÜÔÚ IIS 7.0 ¼¯³ÉģʽÏÂÔËÐÐÒÔ¼°Óë IIS 7.0 »ò¸ü¸ß°æ±¾Ò»ÆðÔËÐÐµÄ ASP.NET Ó¦ÓóÌÐòµÄÓ¦ÓóÌÐòÉúÃüÖÜÆÚ¡£IIS 7.0 »¹Ö§³Ö¾µäģʽ£¬ÆäÐÐΪÀàËÆÓÚÔÚ IIS 6.0 ÖÐÔËÐÐµÄ ASP.NET¡£Óйظü¶àÐÅÏ¢£¬Çë²Î¼û IIS 5.0 ºÍ 6.0 µÄ ASP.NET Ó¦ÓóÌÐòÉúÃüÖÜÆÚ¸ÅÊö¡£
IIS 7.0 ¼¯³É¹ÜµÀÊÇÒ»ÖÖͳһµÄÇëÇó´¦Àí¹ÜµÀ£¬Ëüͬʱ֧ ......
1¡¢ÔÚcompilation Ï£¬ÇëÉèÖÃdebug=false £¬ÈçÏ£º
default Language="c#" debug="false">
2¡¢ÇëʹÓÃServer.Transfer´úÌæResponse.Redirect¡£
3¡¢Ê¹ÓÃValidator¿Ø¼þ£¬ÇëÒª¾³£¼ì²éPage.IsValid¡£
4¡¢ÇëʹÓÃforeachÑ»·£¬¶ø²»ÊÇΪ×Ö·û´®µü´úÑ»·¡£
5¡¢ÇëʹÓÿͻ§¶ËÑéÖ¤·½Ê½(²»ÒªÃ¿´Î¶¼ÔÚ·þÎñ¶ËÑéÖ¤)¡£
6¡¢ÎªÁ˱ÜÃâÖ ......
´ÓÊý¾Ý¿âÈ¡³öÊý¾ÝÈ»ºó¶¯Ì¬µÄÉú³Éhtml¾²Ì¬Ò³Ãæ¡£ÕâÖÖ¼¼ÊõÌØ±ðÊÇÔÚÓµÓдóÁ¿Ò³ÃæµÄÍøÕ¾ÖÐÏÔµÄÌØ±ðµÄÖØÒª
¾ßÌå²½ÖèÎÒÏêϸµÄдһÏÂ
1.½¨Á¢¾²Ì¬Ä£°åÒ³Ãæ¡£Ò²¾ÍÊǽ¨Á¢ÆðÄ£°åÒ³ÃæµÄ¼Ü¹¹
2.È»ºó´Óºǫ́Êý¾Ý¿âÖÐÌáÈ¡ÄÚÈÝ£¬½øÐÐÌæ»»
3.°ÑÌæ»»ºóµÄ×Ö·û´®Ð´ÈëÖÐ
ÎÒÒ²°´ÕÕÉÏÃæµÄ˳Ðò×öһϰÉ
Ê×ÏȽ¨Á¢Ò»¸öÄ£°åHtmlÈ¡ÃûModelHtml.htm. ......
½ñÌìÔÚ·þÎñÆ÷×°ºÃ .net Framework 3.5ºó£¬ÔËÐÐASP.NET ³öÏÖ³ÌÐò´íÎ󣬵«ÊÇÓÖûÓгöÏÖÌØ¶¨³ÌÐò´íÎó£¬Ëµ½Ð²é¿´ÈÕ¼ÇÎļþ£¬Ò»¿´£¬ËµÊ²Ã´ ³ÌÐòÓòÓÐÎÊÌ⣬°Ù¶ÈÖ®ºó£¬ºÜ¹ÜÓ㺠ӦÓóÌÐò³Ø -- ÊôÐÔ -- ±êʶ -- ¸Ä³É ±¾µØÏµÍ³ ÎÊÌâ½â¾ö¡£Ìش˼Ǽ¡£ ......