![]() |
|
|
|||||||
![]() |
ASP Net - How to intercept error when httpRuntime maxRequestLength is exceded. |
|
|
Thread Tools | Search this Thread |
|
|
#11 |
|
[url]http://www.codeproject.com/useritems/FileSelectAndUploadDialog.asp[/url - Charit ----------------------------------------------------------------------- Posted via http://www.codecomments.co ----------------------------------------------------------------------- Charith |
|
|
|
|
#12 |
|
Posts: n/a
|
My pages inherit from a base page so I don't have access to writing
attributes to the form element. You used 2 attributes that I've never used before: enctype and action. Why are you using these and would they have any effect on how errors are trapped in the global.asax? I'm still putting break points on the Application_Error event and also the Global_Error event but these events aren't executing. Can you offer any more advise on how to trap this error so I can redirect to a page with a message to the user? (btw: all of this code is running form a user control which contains all the content for the page, and the page inherits from a base page) The solution mentioned Charith in this thread looks like a good solution, but I'm reluctant to use such JavaScript on the client due to possible problems with downward browsers. Can anyone recommend some proven JavaScript for this? -- "[MSFT]" <> wrote in message news:... > Hello, > > Here is the web form code I use to test, you may test them on your server > to see if they can work: > > <form id="Form1" method="post" enctype="multipart/form-data" > action="WebForm1.aspx" runat="server"> > > <INPUT id="oFile" type="file" runat="server" > NAME="oFile"> > > <br> > > <asp:button id="btnUpload" type="submit" > text="Upload" runat="server"></asp:button> > > <asp Visible="False" > Runat="server"> > > <asp:Label id="lblUploadResult" > Runat="server"></asp:Label> > > </asp > > </form> > > > > > > Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles btnUpload.Click > > Dim strFileName As String > > Dim strFilePath As String > > Dim strFolder As String > > > > strFolder = "C:\Test\" > > > > 'Get the name of the file that is posted. > > strFileName = oFile.PostedFile.FileName > > strFileName = Path.GetFileName(strFileName) > > > > 'Create the directory if it does not exist. > > If (Not Directory.Exists(strFolder)) Then > > Directory.CreateDirectory(strFolder) > > End If > > > > 'Save the uploaded file to the server. > > strFilePath = strFolder & strFileName > > > > If File.Exists(strFilePath) Then > > lblUploadResult.Text = strFileName & " already exists on the > server!" > > Else > > oFile.PostedFile.SaveAs(strFilePath) > > lblUploadResult.Text = strFileName & " has been successfully > uploaded." > > End If > > > > 'Display the result of the upload. > > frmConfirmation.Visible = True > > > > End Sub > > > The problem may be related the web control you use. Therefore, we may begin > with a basic web form for test. > > Luke > moondaddy |
|
|
|
#13 |
|
Posts: n/a
|
I forgot to mention, I also have this setting in my webconfig:
<customErrors mode="Off"/> for testing. could this have any effect on how the Application_Error event fires? -- "moondaddy" <> wrote in message news:%... > My pages inherit from a base page so I don't have access to writing > attributes to the form element. You used 2 attributes that I've never used > before: enctype and action. Why are you using these and would they have > any effect on how errors are trapped in the global.asax? I'm still putting > break points on the Application_Error event and also the Global_Error event > but these events aren't executing. Can you offer any more advise on how to > trap this error so I can redirect to a page with a message to the user? > (btw: all of this code is running form a user control which contains all > the content for the page, and the page inherits from a base page) > > The solution mentioned Charith in this thread looks like a good solution, > but I'm reluctant to use such JavaScript on the client due to possible > problems with downward browsers. Can anyone recommend some proven > JavaScript for this? > > -- > > "[MSFT]" <> wrote in message > news:... > > Hello, > > > > Here is the web form code I use to test, you may test them on your server > > to see if they can work: > > > > <form id="Form1" method="post" enctype="multipart/form-data" > > action="WebForm1.aspx" runat="server"> > > > > <INPUT id="oFile" type="file" runat="server" > > NAME="oFile"> > > > > <br> > > > > <asp:button id="btnUpload" type="submit" > > text="Upload" runat="server"></asp:button> > > > > <asp > Visible="False" > > Runat="server"> > > > > <asp:Label id="lblUploadResult" > > Runat="server"></asp:Label> > > > > </asp > > > > </form> > > > > > > > > > > > > Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles btnUpload.Click > > > > Dim strFileName As String > > > > Dim strFilePath As String > > > > Dim strFolder As String > > > > > > > > strFolder = "C:\Test\" > > > > > > > > 'Get the name of the file that is posted. > > > > strFileName = oFile.PostedFile.FileName > > > > strFileName = Path.GetFileName(strFileName) > > > > > > > > 'Create the directory if it does not exist. > > > > If (Not Directory.Exists(strFolder)) Then > > > > Directory.CreateDirectory(strFolder) > > > > End If > > > > > > > > 'Save the uploaded file to the server. > > > > strFilePath = strFolder & strFileName > > > > > > > > If File.Exists(strFilePath) Then > > > > lblUploadResult.Text = strFileName & " already exists on the > > server!" > > > > Else > > > > oFile.PostedFile.SaveAs(strFilePath) > > > > lblUploadResult.Text = strFileName & " has been successfully > > uploaded." > > > > End If > > > > > > > > 'Display the result of the upload. > > > > frmConfirmation.Visible = True > > > > > > > > End Sub > > > > > > The problem may be related the web control you use. Therefore, we may > begin > > with a basic web form for test. > > > > Luke > > > > moondaddy |
|
|
|
#14 |
|
Posts: n/a
|
This element didn't take any effect on application_error.
Luke [MSFT] |
|
|
|
#15 |
|
Posts: n/a
|
|
|
|
|
#16 |
|
Posts: n/a
|
Hello,
Form's Action property sets or retrieves the URL to which the form content is sent for processing. EncType property sets or retrieves the Multipurpose Internet Mail Extensions (MIME) encoding for the form. Would you please post your client code for the form and <INPUT> component, so I can know what is going on. Regards, Luke [MSFT] |
|
|
|
#17 |
|
Posts: n/a
|
Hello,
I copied your files to my server and made some changes so that it can run in the environment. It worked as expected, code in application_error was executed. The main change I made the files is that I use Windows authentication. I suggest you may create a new project with Windows authentication and add this file to the project, to see if it will work. Luke [MSFT] |
|
|
|
#18 |
|
Posts: n/a
|
OK I'll try it. Thanks for staying with me on this one. I'll make another
post here when I do to let you know what happened. -- "[MSFT]" <> wrote in message news:... > Hello, > > I copied your files to my server and made some changes so that it can run > in the environment. It worked as expected, code in application_error was > executed. The main change I made the files is that I use Windows > authentication. I suggest you may create a new project with Windows > authentication and add this file to the project, to see if it will work. > > Luke > moondaddy |
|
|
|
#19 |
|
Posts: n/a
|
Thanks. I will look forward to your message.
Luke [MSFT] |
|
|
|
#20 |
|
Posts: n/a
|
Greetings all...
I had this issue too... did u all manage to come out with a workaround? regards, Nigil Chua Nigil LaVey |
|