ASP.NETÏÂÔØ——word,txt,ͼƬ·½·¨
ASP.NETÏÂÔØ——word,txt,ͼƬ·½·¨
¡¡¡¡±¾ÎÄÖ÷Òª½éÉÜASP.NETÏÂÔØÖîÈçword,txt,ͼƬµÈµÄ·½·¨¡£
¡¡
¡¡ try
¡¡¡¡{
¡¡¡¡FullFileName = Server.MapPath(FileName); //FileName--ÒªÏÂÔصÄÎļþÃû
¡¡¡¡FileInfo DownloadFile= new FileInfo(FullFileName);
¡¡¡¡if(DownloadFile.Exists)
¡¡¡¡{
¡¡¡¡Response.Clear();
¡¡¡¡Response.ClearHeaders();
¡¡¡¡Response.Buffer=false;
¡¡¡¡Response.ContentType="application/octet-stream";
¡¡¡¡Response.AppendHeader("Content-Disposition","attachment;filename="
¡¡¡¡+HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.ASCII));
¡¡¡¡Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
¡¡¡¡Response.WriteFile(DownloadFile.FullName);
¡¡¡¡Response.Flush();
¡¡¡¡Response.End();
¡¡¡¡}
¡¡¡¡else{
¡¡¡¡//Îļþ²»´æÔÚ
¡¡¡¡}
¡¡¡¡}
¡¡¡¡catch{
¡¡¡¡//Îļþ²»´æÔÚ
Ïà¹ØÎĵµ£º
//ѹËõ
protected void btnY_Click(object sender, EventArgs e)
{
string rar;
RegistryKey reg;
string args;
ProcessStartInfo procStart;
Process process;
try
{
reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command"); ......
½â¾ö°ì·¨£ºapp_code/ ´æ·ÅÒ»¸öÀà ÓÃÀ´½Ø»ñHTTP
1.´úÂëÈçÏÂ
using System;
using System.IO;
using System.Web;
using System.Text;
using System.Text.RegularExpressions;
/// <summary>
/// Removes whitespace from the webpage.
/// </summary>
public class ViewstateModule : IHttpModule
{
......
Ö±½Ó»ñµÃÒ³Ãæ²ÎÊý£º
if(!IsPostBack) { //ÅжÏÊÇ·ñÊǵÚÒ»´Î¼ÓÔØ´°Ìå
}
if(Page.PreviousPage!=null){ // ÅжÏÉÏÒ»Ò³ÃæµÄ°´Å¥ÊÇ· ......