对你的代码进行了测试,我这边没有错误.aspx File Code:
<%@ Page language="c#" Codebehind="TryForm.aspx.cs" AutoEventWireup="false" Inherits="EverythingTry.PrintMethod.TryForm" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>TryForm</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<!-- 加入背景音乐
<bgsound src="PLEASE FORGIVE ME.mp3" loop="infinite" balance="0" volume="0">
-->
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 56px; POSITION: absolute; TOP: 40px" runat="server"
Text="download" Width="72px"></asp:Button></FONT>
</form>
</body>
</HTML>
<%@ Page language="c#" Codebehind="TryForm.aspx.cs" AutoEventWireup="false" Inherits="EverythingTry.PrintMethod.TryForm" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>TryForm</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<!-- 加入背景音乐
<bgsound src="PLEASE FORGIVE ME.mp3" loop="infinite" balance="0" volume="0">
-->
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 56px; POSITION: absolute; TOP: 40px" runat="server"
Text="download" Width="72px"></asp:Button></FONT>
</form>
</body>
</HTML>
解决方案 »
- ASP.NET+C#网站设计中,要统计某个文件的下载次数,有哪几种方法?
- 求REST(Representational State Transfer)学习资料或例子
- 怎么实现省市区树形菜单!打酱油的也来看看嘛!
- 页面加载问题
- 在asp.net中用js文件出错
- 写代码写了有点晕头了,问一个简单的sql语句:
- >>>>新手,问个sql查询,谢谢
- 如果只需要得到5条记录,select语句怎样写?
- IIS 7.5 使用虚拟目录报出的500.19错误
- 在.aspx.cs文件的函数中怎样获得另一页面的返回值?
- VS.NET开发WEB应用程序出错,请高手帮助解决!!
- 如何判断cookies的值为空啊??vb
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;namespace EverythingTry.PrintMethod
{
/// <summary>
/// TryForm 的摘要说明。
/// </summary>
public class TryForm : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string FilePath=Server.MapPath("/EverythingTry")+@"..\AutoCAD\Drawing_1.dwg";
System.IO.FileStream iStream=new FileStream(FilePath,FileMode.Open,FileAccess.Read,FileShare.Read); long FileLength=iStream.Length; long ByteToRead=FileLength; FileInfo fileinfo = new FileInfo(FilePath); String FileName = fileinfo.Name; Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename="+HttpUtility.UrlEncode(FileName,System.Text.Encoding.UTF8)); Response.AddHeader("Content-Length", ByteToRead.ToString()); Response.Flush(); byte[] Buffer; int BufferLength=1000000; int Len=1; bool ClientClosed=false; while (Len>0 && ClientClosed==false)
{
Buffer= new Byte[BufferLength];
Len = iStream.Read(Buffer, 0, BufferLength);
Response.OutputStream.Write(Buffer,0,Len);
Response.Flush();
ClientClosed=!this.Response.IsClientConnected;
} iStream.Close(); iStream = null;
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>人力资源</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body onload="window.document.forms[0].txt_creater.focus()" MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="RecruitSearch.aspx" id="Form1">
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" value="dDwtMTQzNjI4NTA1NTt0PHA8bDxzdHJzcWw7PjtsPHNlbGVjdC这是怎么回事啊,把我的html的一部分也自动加进去了。是不是我设置上面的问题呢?
试试将web.config中的:
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
改成
<globalization requestEncoding="gb2312" responseEncoding="gb2312" />