????? ????? ??? ??? ???? ??? ?? ASP.NET ???????? Visual C# .NET

?????? ????????? ?????? ?????????
???? ???????: 323246 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ???? ????? ??? ????? ????? ??? ??? ???? ??? ???????? Visual C# .NET. ?? ??? ?????? ????? ??? Microsoft ASP.NET (WebForm1.aspx) ???? ??????? ????????? ???????? ??? ????? ????? ?? (WebForm1.aspx.cs) ?????? ????? ??? ???? ?????? ????????.


????? ????? ASP.NET

?? Microsoft Visual Studio .NET ? ???? ??????? ??????? ?????? ????? ???? ?????? ????? ??? ???? ???:
  1. ??? ????? Microsoft Visual Studio .NET.
  2. ?? ??????? ???? ??? ??? ???? ?? ???? ??? ???????.
  3. ?? ???? ?????? ????? ???? ? ???? ??? Visual C# ?????? ??? ????? Project ?? ???? ??? ????? ??? ASP.NET ??? ?????.
  4. ?? ?????? ??????? ???? ????? URL ?????? ???????. ??? ???? ??????? ???? http://localhost/CSharpUpload ? ??? ???? ??? ??? ??????? ????????? CSharpUpload. ???? ?? ????? WebForm1.aspx ????? ?? ????? ????? ???? Visual Studio .NET.

????? ???? ????????

??? ????? ??????? ?????? ?????? "??????" ???? ????? ??????? ??????. ??? ????? ??? ?????? ??? ???? ????? ????? ?????? ????? ????? ???? ASPNET.
  1. ?? ???? "?????? ??????" ?? Visual Studio .NET ???? ??? ?????? ?????? ??? CSharpUpload ???? ??? ????? ?? ???? ??? ???? ????. ?????????? ??? ????? ???? ???? ???? ????? NewFolder1.
  2. ?????? ??? ?????? ??? ?????? ???? ??? ?????? ?????? ??? NewFolder1 ???? ??? ????? ????? ?? ?? ???? ????????.
  3. ?? ?????? "?????? Windows" ??? ?? ???? ???? ???? ???? ??? ???????? ???? ??? ??????? ?? ?????? 2. ??? ??? ??? ?????? ???? ??????? ?? ?????? ??????:
    C:\Inetpub\wwwroot\CSharpUpload\Data
  4. ?????? ?????? ????? ??????? ???? ?????? ??? ?????? "??????" ? ???? ??? ?????? ?????? ??? ?????? ?? ???? ??? ?????.
  5. ?? ???? ?????? ????? ???????? ???? ??? ????? ??????? ???? ?? ???? ??? ?????.
  6. ?? ???? ?????? ????? ???????? ?? ??????? ? ???? ??? ???? ASPNET ?? ???? ??? ?????. ???? ??? ????? ?????? ???? ?????? ????? ???????? ?? ???????.
  7. ???? ??? ???? aspnet_wp (computername \ASPNET) ???? ??? ?? ???? ?????? ????? ?????? ?????? ???????? ???????:

    • ????? ?? ?????
    • ??? ??????? ??????
    • ?????
    • ???????

    ???? ?????? ????? ?? ?????? ? ????? ????? ???????? ??????.
  8. ???? ??? ????? ?????? ???? ?????? ????? ????????. ??? ??? ?????? ?????? ?????? "??????" ????? ????? ???????? ???? ?? ??????? ?????.

????? ?????? WebForm1.aspx

?????? ??????? HTML ?????? ?? ??? WebForm1.aspx ?????? ?????????? ?? ????? ??????? ???? ??????? ???????:
  1. ?????? ??? ???? ????? ?? Visual Studio .NET. ??? ?? ???? WebForm1.aspx ?????? ?? ???? "??????".
  2. ???? ???? HTML ????? WebForm1.aspx ???? ??? ?????? ?????? ??? WebForm1.aspx ?? ???? "??????" ??? ?? ???? ??? ??? ???? HTML.
  3. ????? ???? ??? HTML ??????? ????? ????? ??? ??????? <form>:
    <form id="Form1" method="post" runat="server">
    					
  4. ????? enctype = "multipart/??????? - ??????" ??? - ???? ????? ??? ??????? <form>??? ???:
    <form id="Form1" method="post" enctype="multipart/form-data" runat="server">
    					
  5. ??? ??? <form>??????? ?? ?????? ???????? ???????? ???????:
    <INPUT type=file id=File1 name=File1 runat="server" />
    <br>
    <input type="submit" id="Submit1" value="Upload" runat="server" />
    					
  6. ???? ?? ?? HTML <form>??????? ???? ??? ???:
    <form id="Form1" method="post" enctype="multipart/form-data" runat="server">
    <INPUT type=file id=File1 name=File1 runat="server" />
    <br>
    <input type="submit" id="Submit1" value="Upload" runat="server" />
    </form>
    					

????? ????????? ???????? ??????? ??? ??? ????????? ???????? ??????? WebForm1.aspx.cs

?????? ??? ????????? ???????? ??????? WebForm1.aspx.cs ???? ?????? ???????? ?????? ???? ??????? ???????:
  1. ?? ??????? ???? ???? ??? "?????".
  2. ???? ????? ??????? ??? ?????. ??? ??? ????????? ???????? ??????? WebForm1.aspx.cs Visual Studio ????? ???????? ?????? ???? ???????? ???????? ???????? ?? ??????? ??????:
    private void Submit1_ServerClick(object sender, System.EventArgs e)
    {
    
    
    }
  3. ???? ?? ???? ???????? ???????? ??????? ?? ????? ????? ???? WebForm1.cs:
    protected System.Web.UI.HtmlControls.HtmlInputFile File1;
    protected System.Web.UI.HtmlControls.HtmlInputButton Submit1;
    						
    ??? ??? ???????? ???????? ??? ????? ?? ????? ?????? ???????? ???????? ??? ????? ??? ????? ??????:
    public class WebForm1 : System.Web.UI.Page
    {
    					
  4. ??? ???? ???????? ???????? ???????:
    private void Submit1_ServerClick(object sender, System.EventArgs e)
    {
    					
  5. ???? ENTER ?????? ??? ???? ?? ?? ?????? ???????? ???????? ???????:
    if( ( File1.PostedFile != null ) && ( File1.PostedFile.ContentLength > 0 ) )
    {
    	string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
    	string SaveLocation = Server.MapPath("Data") + "\\" +  fn;
    	try
    	{
    		File1.PostedFile.SaveAs(SaveLocation);
    		Response.Write("The file has been uploaded.");
    	}
    	catch ( Exception ex )
    	{
    		Response.Write("Error: " + ex.Message);
    		//Note: Exception.Message returns a detailed message that describes the current exception. 
    		//For security reasons, we do not recommend that you return Exception.Message to end users in 
    		//production environments. It would be better to put a generic error message. 
    	}
    }
    else
    {
    	Response.Write("Please select a file to upload.");
    }
    ????? ??? ???????? ???????? ????? ?? ????? ???. ??? ?? ????? ?? ??? "? ???? ?????"?????? ????? ??? ?????". ?? ???? ????? ??? ???? ??? ??????? ??? ????? ?? ???? ??????? ????? ????? System.IO ?? ??????? ?????? ?????? ?? ?? ???? SaveAs. ??? ??????? ?????? ???????? ??? ??? ????? ???????? ????? File1.PostedFile.SaveAs. trapped ?? ??????? ????? ????? ????????? ??? ??????.
  6. ???? ?? ???? ??????? ?????? Submit1 ??? ???: ???
    private void Submit1_ServerClick(object sender, System.EventArgs e)
    {
    	if( ( File1.PostedFile != null ) && ( File1.PostedFile.ContentLength > 0 ) )
    	{
    		string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
    		string SaveLocation = Server.MapPath("Data") + "\\" +  fn;
    		try
    		{
    			File1.PostedFile.SaveAs(SaveLocation);
    			Response.Write("The file has been uploaded.");
    		}
    		catch ( Exception ex )
    		{
    			Response.Write("Error: " + ex.Message);
    			//Note: Exception.Message returns detailed message that describes the current exception. 
    			//For security reasons, we do not recommend you return Exception.Message to end users in 
    			//production environments. It would be better just to put a generic error message. 
    		}
    	}
    	else
    	{
    		Response.Write("Please select a file to upload.");
    	}
    }

?????? ???????

????? ?? Visual Studio .NET ?????? ??????? ???? ??????? ???????:
  1. ?? ??????? ????? ? ???? ??? ????? ????.
  2. ?? "?????? ??????" ???? ??? ?????? ?????? ??? WebForm1.aspx ??? ?? ???? ??? ??? ?? ??????.
  3. ??? ??? WebForm1.aspx ?? ???????? ? ???? ??? ???????.
  4. ?? ???? ?????? ?????? ???? ??? ??? ???? ?? 4 ???? ???? ?? ???? ??? ???.
  5. ?????? ????? ???? ??? ?????. ???? ?????? ????? ??? ???? ??? ???? ????? "????? ??? ?????".
  6. ?????? ??? ???? ????? ?? ?????? Windows ??? ?? ???? ???? ?????? "??????".
  7. ???? ?? ????? ????? ??? ?????? ??????.

????? ????? ????

???? ???????? ASP.NET ??? ???? ??????? 4,096 ???????? (KB) (?? 4 ???? ????) ?? ??? ????? ??? ???? ???. ??? ????? ????? maxRequestLength<httpruntime>?????? ????? ???? ????? ???? ?? ??? Web.config.

?????? ????? ??? ????? ????? maxRequestLength ?? ????? Machine.config ??? ?? ?? ??? ??? (??? ???? ??????? ????? ???) ???? ?????? ???? maxRequestLength ? ????? ??? ???? ??? ?????. ????? ?? ???? Microsoft Internet Explorer ???? ????? ??? "????? ?????? ??? ?????? ?? DNS".

??? ??? ???? ?? ????? ??? ??????? ?? ??? ????????? ????? ???? ????? ASP.NET ??? ??? ????? Machine.config ?? ?????.

?????????? <httpruntime> ????? ?????? ??? ???????? ??????? ?? Machine.config ?????:
<httpRuntime 
executionTimeout="90" 
maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false" 
minFreeThreads="8" 
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"
/>
				
???? ????? Machine.config ?? \ ?????? \CONFIG Version Number \Microsoft.NET\Framework\ System Root.


????? ??? ????????? ????????

WebForm1.aspx

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="CSharpUpload.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
    <title>WebForm1</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name=vs_defaultClientScript content="JavaScript">
    <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
  </HEAD>
  <body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" enctype="multipart/form-data" runat="server">
<INPUT type=file id=File1 name=File1 runat="server" >
<br>
<input type="submit" id="Submit1" value="Upload" runat="server" NAME="Submit1">
</form>

	
  </body>
</HTML>
				

WebForm1.aspx.cs

using System;
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;

namespace CSharpUpload
{
	/// <summary>
	/// Summary description for WebForm1.
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
	{
		protected System.Web.UI.HtmlControls.HtmlInputFile File1;
		protected System.Web.UI.HtmlControls.HtmlInputButton Submit1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			// 
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			// 
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Submit1.ServerClick += new System.EventHandler(this.Submit1_ServerClick);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Submit1_ServerClick(object sender, System.EventArgs e)
		{
			if( ( File1.PostedFile != null ) && ( File1.PostedFile.ContentLength > 0 ) )
			{
				string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
				string SaveLocation = Server.MapPath("Data") + "\\" +  fn;
				try
				{
					File1.PostedFile.SaveAs(SaveLocation);
					Response.Write("The file has been uploaded.");
				}
				catch ( Exception ex )
				{
					Response.Write("Error: " + ex.Message);
					//Note: Exception.Message returns a detailed message that describes the current exception. 
					//For security reasons, we do not recommend that you return Exception.Message to end users in 
					//production environments. It would be better to return a generic error message. 
				}
			}
			else
			{
				Response.Write("Please select a file to upload.");
			}
		}
	}
}
	

??????? ????

?????? ? ??? ??????? ?????? ???? ??? ????. ??? ???? ????? ?????? ????? ASP.NET ?? ???? ????? ????? ????? ????? ?????? ?? ASP.NET. ?? ?????? ???? ASP.NET ????? ????? ?????? ?? ? ???????? (GB). ??? ???? ?????? ????? ?????? ASP.NET ??? ???? ?????? ?? ? ???????? ???? ?????? ????? ?????? ????????.

????? ????? ??????? ASP.NET ?????? ????? ?????? ?? ??????? ??? ?? ???????? ????? ??? ????? ??? ?????. ????? ?? ????????? ??????? ????? ??? memoryLimit ??????? processModel ?? ????? Machine.config. ???? ????? memoryLimit ???? ?????? ???? ??????? ??????? ?????? ???? ASP.NET ??? ???????? ????? ??????? ???????. ????? ???? ???? ??????? ?? ?????? ?? ASP.NET ???? ?? ????? ?? ?????????.

???????? ??? ???? ???? ????? ???? ????? ?? ??? ????? ?????? ???? ???? ??????. ????? ??? ??????? ??????? ??????? ??????? ???????? ??? ????? ?????? ??????? ??????? ???? ???? ???? ??????? ??????. ?? ???? ???? ???? ?? ??????? ???? ?? ??????? ???? Microsoft ???????? ??? ???? ????? ?? ?????? ?? ?? ??? ?? ???????? (MB). ?? ???? ?????? ?? ?? ????? ????? ?? ???? ?????? ???? ????? 100 ???? ????.

?????? ????? ????? ??????? ???? ????? ???? ?? 100 ???? ???? ?? ASP.NET. ??? ????? ?? ???? ???? Microsoft ?????? ????? ????? ????? ?????? ???????? ?? ??? ???????. ?????? ????? ??????? ???? ??? ????? ????? ?????? ??? ????? ????????? ???? ???? ??? ???? ???? ????????? ?? ???????.

?? ????? ?????? ????? ????????? ?? ???? ?????? ???? ??? ????? ????? ????? ????? ?????:
  • ?? ???? ??? ??????.
  • ??? ????? ?????? Unavailable
    ?? ??? ????? ???? ????? ??? ?????? ??? ???:

    ????? aspnet_wp.exe (???? ???????: PIDNumber) ?? ????? ??????? ???? ????? ??????? ??????? SizeLimit ???????? (Percentage ?????? ??????? RAM ????????).

  • ?? ??? System.OutOfMemoryException ??????? ???.
?? ??? ????? ???? ?????? ??????? ???? ????. ?? ???? ?????? ????? Aspnet_wp.exe ?? "????? ???? Windows ?????? ???? ???? ??????? ?????? 64 ???????? ?? ????? 1 ?? 2. ???????? ??? ??? ????? ?? ???? ??? ??????? ??????? ???????? ASP.NET ????????? ????? ????? ??? responseDeadlock.

?????

?????? ??? ???? ?? ?????????? ?? ?????? ?????? Microsoft Network (MSDN) ????? ????? ???????;
???? <httpruntime>
http://msdn2.microsoft.com/en-us/library/e1f13641(vs.71).aspx

???? ??????? | ???? ?????
http://msdn.microsoft.com/en-us/library/ms535260(VS.85).aspx

??? ENCTYPE | ??????? enctype
http://msdn2.microsoft.com/en-us/library/ms533745.aspx

??? HtmlInputFile
http://msdn2.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlinputfile(vs.71).aspx

??????? HtmlInputFile.PostedFile
http://msdn2.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlinputfile.postedfile(vs.71).aspx

???????

???? ???????: 323246 - ????? ??? ??????: 04/????? ??????/1428 - ??????: 5.11
????? ???
  • Microsoft ASP.NET 1.0
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft ASP.NET 1.1
  • Microsoft Visual C# .NET 2003 Standard Edition
????? ??????: 
kbmt kbhowtomaster KB323246 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????323246

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com