This is a migrated thread and some comments may be shown as answers.

Issue with upload in grid edit form

3 Answers 37 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Senthil
Top achievements
Rank 1
Senthil asked on 29 Aug 2013, 06:13 PM
There is a radgrid in my web application and I am displaying its edit form a user control. The grid edit form has an upload control to upload files. All were working fine when I run this application from localhost and once this application is moved to IIS7 on the windows server 2008 production server, the upload is not working. Everything works fine if I edit without upload a file. If I upload a file and try to save the edit form, IE displays it cannot find display the page and MF says that the connection has been reset.

Not sure what is causing this issue with the same application on IIS.
Senthil

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 30 Aug 2013, 05:49 AM
Hi Senthil,

Such an issue can happen when you are trying to upload large files. Try the following settings for IIS 7 in the web.config file.

XML:
<system.webserver>
...
<security >
    <requestFiltering>
        <requestLimits maxAllowedContentLength="1024000000" />
    </requestFiltering>
</security>
</system.webserver>

Open the file C:\Windows\System32\inetsrv\config\applicationHost.config and find the line:

<section name="requestFiltering" overrideModeDefault="Deny" />

Set the overrideModeDefault property to Allow.

You can also set a higher value for the executionTimeout property since network traffic can also sometimes lead to such an issue.

Thanks,
Shinu.

0
Senthil
Top achievements
Rank 1
answered on 06 Sep 2013, 02:59 AM
Thanks shinu. I fixed the problem with web.config. Heres another requirement. The scenario is to upload files with total size not exceeding 5 mb. I need C# and suppose the size exceed 5mb the rest of the files shouldnt be saved on the server and discarded. Also alert user about those files which are not uploaded.
0
Accepted
Shinu
Top achievements
Rank 1
answered on 06 Sep 2013, 05:31 AM
Hi Senthil,

Please have a look into the following code I tried which works fine at my end.

ASPX:
<div>
    Select Files with total size upto 5 MB.<br />
    <br />
    <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" Skin="Silk" TargetFolder="~/Images/Img/"
        AllowedFileExtensions=".jpg,.zip" MaxFileSize="579371152" MultipleFileSelection="Automatic"
        UploadedFilesRendering="BelowFileInput" OnFileUploaded="RadAsyncUpload1_FileUploaded">
    </telerik:RadAsyncUpload>
    <br />
    <br />
    <telerik:RadButton ID="RadButton1" runat="server" Text="Upload" OnClick="RadButton1_Click">
    </telerik:RadButton>
    <asp:HiddenField ID="HiddenField1" runat="server" />
</div>

C#:
const int MaxTotalBytes = 5242880;
Int64 UploadedBytes;
 
protected void Page_Load(object sender, EventArgs e)
{
 
}
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
{
    UploadedBytes += e.File.ContentLength;
    if (UploadedBytes <= MaxTotalBytes)
    {
        string targetfolder = RadAsyncUpload1.TargetFolder;
        e.File.SaveAs(Path.Combine(Server.MapPath(targetfolder), e.File.FileName));  
    }
    else
    {
        e.IsValid = false;
        UploadedBytes -= e.File.ContentLength;
        HiddenField1.Value = HiddenField1.Value + e.File.FileName + " ";
    }
}
protected void RadButton1_Click(object sender, EventArgs e)
{
    if (!String.IsNullOrEmpty(HiddenField1.Value))
    {
        Response.Write("<script>alert('" + HiddenField1.Value + "'+' not uploaded')</script>");
    }
    HiddenField1.Value = "";
}

Thanks,
Shinu.
Tags
AsyncUpload
Asked by
Senthil
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Senthil
Top achievements
Rank 1
Share this question
or