Welcome Guest Search | Active Topics | Sign In | Register

E.O Ajax Uploader freezes Options
femotee
Posted: Tuesday, January 15, 2008 4:29:00 AM
Rank: Member
Groups: Member

Joined: 11/16/2007
Posts: 13
I need help with the Ajax uploader. It freezes when the upload button is clicked. I really don't understand it. What additional info do you need to assist on solving the issue

Below is the file:
<%@ Page Language="VB" MasterPageFile="~/MasterFiles/NoLinks.master" Theme="profile" AutoEventWireup="false" CodeFile="UpLoadPhoto.aspx.vb" Inherits="UpLoadPhoto" title="Upload Photo - localhost/churchsite" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<div class="pageDescription">Upload profile photo <asp:Label ID="lbUser" runat="server" Text="Label"></asp:Label></div>
<br />
<br />
<div style="font-family:Verdana; font-size:9pt;">Uploading your photo increase your chances of meeting new friends and developing a wide network. Photo
may not contain nudity, sexually explicit content, violent or offensive material or copyrighted images. Do not load images of other people
without prior consent.</div>
<br />
<br />

<table border="0" cellpadding="2" cellspacing="2">
<tr><td style="width:500px;">
<div>
<div class="topLabel">Upload profile photo</div>
<p></p>
<span style="color:Navy; font-size:9pt;">
1. Click the "Browse" button to select the file location on your computer.<br />
2. Click the "Upload selected button" to upload your photo to legwork.com.ng servers.<br />
3. Enter a caption to describe the photo.<br />
4. Click "Save uploaded photo" to save the photo to your profile.
</span> <p></p>
Photo must be less than <b>500 KB</b>. See the help section on how to check file size or resize photos.<br />
Acceptable image formats are - *.jpg, *.gif, *.Jpeg or *.bmp. Trying to upload a photo that does not meet the specifications might result in errors.
</div>
<div>
<div>
<asp:Label ID="lbMsg" ForeColor="Black" BackColor="yellow" Font-Bold="true" runat="server" Text="Photo saved successfully." Visible="false"></asp:Label><br />
<eo:AJAXUploader ID="AJAXUploader1" runat="server" Width="300px" AllowedExtension=".bmp|.jpg|.png|.gif|.jpeg" TempFileLocation="~/write/upload/" MaxDataSize="1000" MaxFileCount="1" Rows="1" >
</eo:AJAXUploader>
</div> <br /><br />
<div><asp:Label ID="lbCaption" runat="server" Text="Enter a caption for your photo:">
</asp:Label><br /></div>
<div>
<asp:TextBox ID="txtCaption"
runat="server" Width="300px" MaxLength="30" BackColor="lemonchiffon"></asp:TextBox>
<br />
<br />
</div>
</div> </td></tr>
<tr><td align="right"><asp:Button ID="BtnUpload" runat="server" Text="Save uploaded photo" />&nbsp&nbsp&nbsp&nbsp&nbsp;<asp:Button ID="BtnSkip" CausesValidation="false" runat="server" Text="Skip upload" Font-Size="8pt" />

<p></p>
<asp:Label ID="lbError" ForeColor="red" Font-Bold="true" runat="server" Text=""></asp:Label>

</td></tr>

</table>
<asp:HiddenField ID="HfUserId" runat="server" />
<asp:HiddenField ID="hfUserName" runat="server" />
<asp:HiddenField ID="hffirstName" runat="server" />
</asp:Content>

And the code behind:

Imports System.IO

Partial Class UpLoadPhoto
Inherits System.Web.UI.Page

Public ReadOnly Property userId() As String
Get
Return hfUserId.Value
End Get
End Property
Public ReadOnly Property firstName() As String
Get
Return hfFirstName.Value
End Get
End Property

Public ReadOnly Property userName() As String
Get
Return hfUserName.Value
End Get
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
EO.Web.Runtime.DebugLevel = 0
If Not String.IsNullOrEmpty(Request.QueryString("userToken")) Then
Dim usertoken As String = Request.QueryString("userToken")
Dim iMem As Member = Member.getByRegisterToken(usertoken)

If Not IsNothing(iMem) Then
lbUser.Text = String.Format("for {0}", iMem.firstName)
HfUserId.Value = iMem.userid
hfUserName.Value = iMem.userName
hffirstName.Value = iMem.firstName
End If
Else
Response.Redirect("http://localhost/profile/signup/signup1.aspx")

End If
End If
End Sub

Protected Sub BtnSkip_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSkip.Click
Response.Redirect(String.Format("http://localhost/profile/signup/JoinSchool.aspx?userToken={0}", Request.QueryString("userToken")))
End Sub

Private Function getFullHttpUrl(ByVal filePath As String) As String
If Not String.IsNullOrEmpty(filePath) Then
filePath = filePath.TrimStart("~")
filePath = String.Concat("http://localhost/profile", filePath)
Else
filePath = ""
End If
Return filePath
End Function

Protected Sub AJAXUploader1_FileUploaded(ByVal sender As Object, ByVal e As System.EventArgs) Handles AJAXUploader1.FileUploaded
Dim userId As String = HfUserId.Value
If Convert.ToInt32(userId) > 0 Then
Dim iFiles As EO.Web.AJAXPostedFile() = AJAXUploader1.PostedFiles
Dim iCount As Integer = iFiles.Length
Dim sImageLocation As String = "~/Write/Profile"
For i As Integer = 0 To (iCount - 1)

Dim eFile As EO.Web.AJAXPostedFile = CType(iFiles.GetValue(i), EO.Web.AJAXPostedFile)
Dim fiUpload As FileInfo = New FileInfo(System.IO.Path.GetFullPath(eFile.TempFileName))
If fiUpload.Exists Then
'rewrite file
Dim newFileName As String = String.Format("{0}\_{1}_{2}", fiUpload.DirectoryName, userId, eFile.ClientFileName)
fiUpload.MoveTo(newFileName)

'Get the name of file to save photo
Dim smallPhotoUrl As String = Photo.getVirtualPath(sImageLocation, "smallImage", userId)
Dim mediumPhotoUrl As String = Photo.getVirtualPath(sImageLocation, "midImage", userId)
Dim largePhotoUrl As String = Photo.getVirtualPath(sImageLocation, "largeImage", userId)

'Resize images & write to folder
Photo.writePhoto(Photo.ResizeImageFile(newFileName, PhotoSize.Small), Photo.getImageLocation(smallPhotoUrl, Context))
Photo.writePhoto(Photo.ResizeImageFile(newFileName, PhotoSize.Medium), Photo.getImageLocation(mediumPhotoUrl, Context))
Photo.writePhoto(Photo.ResizeImageFile(newFileName, PhotoSize.Full), Photo.getImageLocation(largePhotoUrl, Context))

'Save hyperlink of photos to database
MyProfile.insertPictures(getFullHttpUrl(smallPhotoUrl), getFullHttpUrl(mediumPhotoUrl), getFullHttpUrl(largePhotoUrl), userId, txtCaption.Text)
'delete original photo
fiUpload.Delete()
End If
Next
Response.Redirect(String.Format("http://localhost/profile/signup/joinschool.aspx?userToken={0}", Request.QueryString("userToken")))
End If
End Sub
End Class
eo_support
Posted: Tuesday, January 15, 2008 5:19:39 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Please try to run the demo from the latest version and see if it works. That can tell whether it has to do with your project/server or not.

Thanks
femotee
Posted: Tuesday, January 15, 2008 7:04:37 AM
Rank: Member
Groups: Member

Joined: 11/16/2007
Posts: 13
I don't have the problem on development only in production
eo_support
Posted: Tuesday, January 15, 2008 7:38:12 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

What's occuring most likely is some other modules buffered the input data before it reaches our uploader. There are two typical situations:

1. Your IIS to configured to have a huge receive buffer. When that occurs, the whole request is not handed over to ASP.NET before that buffer runs out;
2. ASP.NET tracing is enabled on your server. ASP.NET tracing intercepts everything before everybody else. And it attemps to read the whole input data;

In either case, The AJAXUploader appears to be freezing because the server side code is still waiting for another module to hand the control over (You can wait long enough and see what happens, that may give you more information). There are also third party solutions that may cause the same problem due to the same cause.

Also, if you have disabled client side debug message (see details here: http://www.essentialobjects.com/ViewDoc.aspx?t=EO.Web.Runtime.DebugLevel.html), you may want to re-enable it so that if we show any debug message, you will be able to see it.

Thanks
Brad Peters
Posted: Wednesday, April 16, 2008 11:15:46 PM
Rank: Newbie
Groups: Member

Joined: 4/12/2008
Posts: 3
I'm having the same issue. However, my uploader freezes only for big files (~ >20MB). It works fine for 5-10MB files. For the larger one it just hangs. Debugging is enabled and there is no ASP.NET tracing on my page. As with the other person, it works fine in my development (i.e. run from within Visual Studio) environment, but doesn't work in production - IIS.
eo_support
Posted: Friday, April 18, 2008 8:46:17 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi Brad,

We have looked into issue and it appears that your issue is caused by a new IIS setting that restricts the content length of a request. You can find more details about this issue at here:

http://forums.iis.net/p/1108662/1705324.aspx

And here:

http://www.milka.dk/Main/2007/07/03/IIS7RequestFiltering.aspx

You would need to change maxAllowedContentLength. When the size of the request is over maxAllowedContentLength, IIS would just fail the request without even hand it over to ASP.NET, so our server side code don't even see a request.

Thanks
Brad Peters
Posted: Friday, April 18, 2008 9:36:39 AM
Rank: Newbie
Groups: Member

Joined: 4/12/2008
Posts: 3
OK. I will try that. However, I was under the impression (and there is absolutely no description of how AjaxUploader actually works), that it was managing the upload stream, not IIS's form processing. So I never would have guessed that the maxcontentlength, which applies to form input, would apply here. To be honest, the opaqueness of how AjaxUploader works is concerning (for instance, I don't really know how much overhead AjaxUploader adds to the upload process).
eo_support
Posted: Friday, April 18, 2008 9:54:40 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi Brad,

Everything still go through HTTP and IIS. IIS listens HTTP connection, take a peek of it and then hand it over to ASP.NET if necessary. Our uploader lives in the .NET world so it's at the end of the chain.

The main difference between our uploader and a regular HTTP upload is that our uploader uses a separate connection to submit the file, as opposes to using the same connection with regular file input element. That's why with a regular upload the page freezes until the upload is done, but with our uploader the page is still responsive. The files themselves are still uploaded the same way as far as from HTTP/IIS point of view, we do not split files or whatsoever. We add a few more form variables to the request so that our server side code knows the upload is initiated by us, but the size of those variables are negligible comparing to the size of the real file data.

We’ve run a test on your server by uploading a big file with regular HTML file input element (you will see a test.html) on your server. That also fails due to the same IIS restriction you have on your server. You will see the page freezes for a long time (which is normal for uploading a big file) and then get a HTTP 404 error. You would have no get such an error if the upload were successful. The test use a regular HTML file with a single file input element, so it doesn’t even go through ASP.NET. We noticed the same error when we trace our uploader.

Hope this clears up. Please let us know if you have any more questions!

Thanks
Brad Peters
Posted: Friday, April 18, 2008 10:17:13 AM
Rank: Newbie
Groups: Member

Joined: 4/12/2008
Posts: 3
OK. Highly obscure config setting:

appcmd set config "My Site/MyApp" -section:requestFiltering -requestLimits.maxAllowedContentLength:104857600 -commitpath:apphost

but it works
eo_support
Posted: Friday, April 18, 2008 10:48:19 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Awesome. Thanks for letting us know!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.