Re: Upload a File to a Web Server and error handling

From: Al Smith (asmith_at_NOSPAMmrisystem.com)
Date: 02/04/04


Date: Wed, 4 Feb 2004 08:57:56 -0500

Thanks Brian,

I'll give that a try.

Al

"Brian Combs" <Brian@online.microsoft.com> wrote in message
news:KJrPfCn6DHA.1988@cpmsftngxa07.phx.gbl...
> Hello
> You should be able to trap the error in the Application_Error event
handler
> in the global.asax file and then redirect the reqeust to your own custom
> error page. Take a look at the following article for how to create custom
> error reporting pages.
> 306355 HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using
> Visual
> http://support.microsoft.com/?id=306355
>
> This would be better then trying to do this in an HttpModule.
>
> Thanks
> Brian [MS]
> Microsoft Developer Support
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> --------------------
> | From: "Al Smith" <asmith@NOSPAMmrisystem.com>
> | References: <uSEvkB63DHA.1052@TK2MSFTNGP12.phx.gbl>
> <23333741-EFE1-4D89-81C1-BB8FECB57201@microsoft.com>
> <e7jK7Z63DHA.2428@tk2msftngp13.phx.gbl>
> <m7VFGZr5DHA.1992@cpmsftngxa07.phx.gbl>
> | Subject: Re: Upload a File to a Web Server and error handling
> | Date: Thu, 29 Jan 2004 22:01:42 -0500
> | Lines: 104
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
> | Message-ID: <uF98k1t5DHA.1948@TK2MSFTNGP12.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | NNTP-Posting-Host: 12.17.95.135
> | Path:
>
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
> phx.gbl!TK2MSFTNGP12.phx.gbl
> | Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.aspnet:206313
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> |
> | Thanks Brian,
> |
> | I am beginning to think ISAPI is the only solution. Thanks and I;ll
check
> | back.
> |
> | Al
> |
> | "Brian Combs" <Brian@online.microsoft.com> wrote in message
> | news:m7VFGZr5DHA.1992@cpmsftngxa07.phx.gbl...
> | > Hello
> | > It looks like framework may handle the maxRequestLength and not allow
> you
> | > to handle error unless you want to set the size to be very large and
> then
> | > you can handle checking the size of the request in your code and send
> back
> | > error. I will do some checking to see if there is any way we can trap
> the
> | > return data and modify it in managed code. However if framework
handles
> | > this without going through pipline then your only options will be to
set
> | it
> | > to a large size and do your own checking or create ISAPI filter.
> | >
> | > Thanks
> | > Brian [MS]
> | > Microsoft Developer Support
> | > This posting is provided "AS IS" with no warranties, and confers no
> | rights.
> | > --------------------
> | > | From: "Al Smith" <asmith@NOSPAMmrisystem.com>
> | > | References: <uSEvkB63DHA.1052@TK2MSFTNGP12.phx.gbl>
> | > <23333741-EFE1-4D89-81C1-BB8FECB57201@microsoft.com>
> | > | Subject: Re: Upload a File to a Web Server and error handling
> | > | Date: Tue, 20 Jan 2004 17:41:00 -0500
> | > | Lines: 50
> | > | X-Priority: 3
> | > | X-MSMail-Priority: Normal
> | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
> | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
> | > | Message-ID: <e7jK7Z63DHA.2428@tk2msftngp13.phx.gbl>
> | > | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | > | NNTP-Posting-Host: 12.17.95.135
> | > | Path:
> | >
> |
>
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.
> | > phx.gbl
> | > | Xref: cpmsftngxa07.phx.gbl
> | microsoft.public.dotnet.framework.aspnet:203673
> | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> | > |
> | > | Hi Joji,
> | > |
> | > | My problem is when the byte count of the file exceeds the
> | maxRequestLength
> | > | parameter of the <httpRuntime> area of the web.config file and how
to
> | trap
> | > | that error. So the name of the file is not an issue... at least
yet,
> or
> | > did
> | > | I miss understand something here.
> | > |
> | > | Thanks
> | > | Al
> | > |
> | > |
> | > |
> | > | "Joji" <joji_ninan@yahoo.com> wrote in message
> | > | news:23333741-EFE1-4D89-81C1-BB8FECB57201@microsoft.com...
> | > | > Al Smith you can try this -
> | > | >
> | > | > Dim strFolderDetail As String =
> | > | "C:\inetpub\wwwroot\MYPROJECTFOLDER\uploads\"
> | > | >
> | > | > 'Grab the file name from its fully qualified path at
client
> | > | > Dim strFileName As String =
controlName.PostedFile.FileName
> | > | >
> | > | > ' only the attched file name not its path
> | > | > Dim strNewFileName As String =
> | > | System.IO.Path.GetFileNameWithoutExtension(strFileName) & _
> | > | >
> | > | String.Format("{0:MMddyyHHmmss}", Date.Now) & _
> | > | >
> | > | System.IO.Path.GetExtension(strFileName)
> | > | >
> | > | >
> | > | > 'Save uploaded file to server at C:\ServerFolder
Try
> | > | > controlname.PostedFile.SaveAs(strFolderDetail +
> | > | strNewFileName)
> | > | > Response.Write("Your File Uploaded Sucessfully at
server
> | > as: "
> | > | & strNewFileName)
> | > | >
> | > | > Catch Exp As Exception
> | > | > Response.Write(Exp.Message)
> | > | > End Try
> | > | > --------------
> | > | >
> | > | > in you aspx page you have to put
> | > | >
> | > | > <INPUT id="controlName" type="file" size="40" name="controlName"
> | > | runat="server">
> | > | > Let me know if you have any problem running this.
> | > | > Joji
> | > |
> | > |
> | > |
> | >
> |
> |
> |
>



Relevant Pages