제목 : Re : Re : 파일 업로드시 용량 초과 예외 처리 질문합니다.
글번호:
|
|
611
|
작성자:
|
|
박은미
|
작성일:
|
|
2007/06/04 오후 3:11:00
|
조회수:
|
|
5006
|
와우~ 선생님이 직접 답을 해주셨네요.. ^ ^ 감솨합니다..
수업 받을때의 생각이 많이 나네요..
물론 주신 소스로 바로 수정해 보았는데..
Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Maximum request length exceeded.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Maximum request length exceeded.]
System.Web.HttpRequest.GetEntireRawContent() +3226525
System.Web.HttpRequest.GetMultipartContent() +56
System.Web.HttpRequest.FillInFormCollection() +264
System.Web.HttpRequest.get_Form() +65
System.Web.HttpRequest.get_HasForm() +57
System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +2025185
System.Web.UI.Page.DeterminePostBackMode() +60
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +133
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
이런 메세지가 없어지지를 않아요..
레이블 Text 도 바뀌지를 않구요..
**********************소스 코드 qnaWriteControl.ascx.cs*******
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class QNA_QnaWriteControl : System.Web.UI.UserControl
{
#region Private Members Variable
private string directory = String.Empty;
private string filename = String.Empty;
private int i = 0;
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Page.User.Identity.IsAuthenticated)
{
MemberInfo info2 = new MemberInfo();
info2 = MemberController.ViewMembers(Convert.ToInt32(Request.Cookies["MemberID"].Value));
this.txtName.Text = info2.Name;
}
}
}
protected void btnWrite_Click(object sender, ImageClickEventArgs e)
{
QnaInfo objQnaInfo = new QnaInfo();
objQnaInfo.Subject =lstSubject.SelectedValue;
objQnaInfo.Name = txtName.Text.Replace("&", "&").Replace("<", "<").Replace(">", ">")
.Replace("\r\n", "<br/>").Replace("/t", " ");
objQnaInfo.Title = txtTitle.Text.Replace("&", "&").Replace("<", "<").Replace(">", ">")
.Replace("\r\n", "<br/>").Replace("/t", " ");
objQnaInfo.Content = txtContent.Text;
objQnaInfo.Encoding = lstEncoding.SelectedValue;
objQnaInfo.Password = txtPassword.Text;
objQnaInfo.PostIP = Request.UserHostAddress;
//파일 업로드 기능
if (ctlFileUpload.PostedFile.FileName != null)
{
if (ctlFileUpload.PostedFile.FileName.Trim().Length > 0 &&
ctlFileUpload.PostedFile.ContentLength > 0)
{
objQnaInfo.FileName = GetFilePath(Server.MapPath("./Files"), ctlFileUpload.FileName);
objQnaInfo.FileSize = ctlFileUpload.PostedFile.ContentLength;
if (objQnaInfo.FileSize > 4096000)
{
this.lblResult.Text = "4M 이하 용량만 업로드 가능합니다. 화일이 큽니다.";
Response.End();
}
else
{
ctlFileUpload.PostedFile.SaveAs(objQnaInfo.FileName);
objQnaInfo.FileName = Path.GetFileName(objQnaInfo.FileName);
}
}
else
{
objQnaInfo.FileName = String.Empty;
}
}
QnaDataProvider.Instance().WriteQna(objQnaInfo);
Response.Redirect("QnaList.aspx");
}
#region 파일 중복처리 메서드
private string GetFilePath(string directory, string filename)
{
string strName = Path.GetFileNameWithoutExtension(filename);
string strExt = Path.GetExtension(filename);
bool blnExists = true;
int i = 0;
while (blnExists)
{
if (File.Exists(Path.Combine(directory, filename)))
{
i++;
filename = strName + "(" + i + ")" + strExt;
}
else
{
blnExists = false;
}
}
return Path.Combine(directory, filename);
}
#endregion
protected void btnCancle_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("QnaList.aspx");
}
}
가 이렇게 됩니다.. 뭐가 잘 못된건지요. 다시 한번 봐주심 감사하겠습니다.