C1Upload Does Not Copy To Target folder

Posted by: chart352 on 10 September 2017, 11:40 am EST

  • Posted 10 September 2017, 11:40 am EST

    Hi,
    I am trying to get a simple page with C1Upload to work. After following the instructions in the help file, the page uploads the file to the Temp folder but does not copy it to the Target folder. I have the same problem if the app is running under IIS7 or IIS6. My version of C1.Web.UI.3.dll is 3.5.20102.74

    Here is the code:


    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="sendmailattachfile.aspx.cs" Inherits="thesite.sendmail.sendmailattachfile" %>

    <%@ Register Assembly="C1.Web.UI.Controls.3" Namespace="C1.Web.UI.Controls.C1Upload"
    TagPrefix="cc1" %>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>Edit Email Attachments</title>
    <link rel="stylesheet" type="text/css" href="/common/XP.css" />
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <table width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td>
    <cc1:C1Upload ID="C1Upload1" runat="server" Width='250px' MaximumFiles="5" OnValidatingFile="C1Upload1_ValidatingFile" />
    </td>
    </tr>
    <tr>
    <td width="100%" colspan="2">


    <font size="2"><b>Attached Files:</b></font>


    </td>
    </tr>
    <tr>
    <td width="100%" colspan="2"><font size="2">No Files Attached</font></td>
    </tr>
    <tr>
    <td width="100%" align="center" colspan="2">
    <input type="button" value="Done" id="cmdDone" name="cmdDone" onclick="javascript:window.close();" />
    </td>
    </tr>
    </table>
    </div>
    </form>
    </body>
    </html>



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.IO;
    using System.Configuration;
    using C1.Web.UI.Controls.C1Upload;

    namespace thesite.sendmail
    {
    public partial class sendmailattachfile : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    string temp = Server.MapPath(ConfigurationManager.AppSettings["TempPath"]);
    C1Upload1.TempFolder = temp;
    if (!Directory.Exists(temp))
    {
    Directory.CreateDirectory(temp);
    }

    string target = Server.MapPath(ConfigurationManager.AppSettings["UploadPath"]);
    C1Upload1.TargetPhysicalFolder = target;
    //C1Upload1.TargetFolder = ConfigurationManager.AppSettings["UploadPath"];
    if (!Directory.Exists(target))
    {
    Directory.CreateDirectory(target);
    }
    }
    }

    protected void C1Upload1_ValidatingFile(object sender, ValidateFileEventArgs e)
    {

    // // The path parameter in the SaveAs method could be generated by user’s real logic.
    // string target = Server.MapPath(ConfigurationManager.AppSettings["UploadPath"]);

    // e.UploadedFile.SaveAs(target+"test.jpg", true);

    }


    }
    }


    By the way, ValidatingFile event never fires.

    Any Suggestions?

    Thanks.
  • Replied 10 September 2017, 11:40 am EST

    I have had similar problem(s) with C1Upload, please note I have everything working on a IIS6 server with dotnet 3.5 and am trying to move it to a IIS7 server with dotnet 4.0

    On the IIS7 server the first problem I had was:
    Can't get the upload progress

    which was resolved by Steve:
    Posted by steve@enterprisestudy.com
    on 4-19-2010 4:20 AM
    Hi,

    I've found the problem. Your 'Register in web.config' doesn't register the settings correctly for IIS 7.

    You also need to add:

    <system.webServer>
    <handlers>
    <add name="C1UploadProgress" path="C1UploadProgress.axd" verb="*" type="C1.Web.UI.Controls.C1Upload.UploadProgressHandler,C1.Web.UI.Controls.3" resourceType="Unspecified" preCondition="integratedMode"/>

    of course I changed the .3s to .4s in the web.config so now the progress bar shows up but stays at 0% for a few seconds then the screen refreshes and it doesn't seem as if the validate event fires, nothing is in the temp folder, permissions are the same as the IIS6 server. Are there any other web.config differences for IIS7 that might be preventing the file from being uploaded?
  • Replied 10 September 2017, 11:40 am EST

    I added a simple log to verify
    1) This isn't a permissions problem (the log file is written to both C1Upload1.TempFolder and C1Upload1.TargetPhysicalFolder)
    2) The ValidatingFile event is not firing :

    public void WriteLog(string LogEntry)
    {
    using (System.IO.StreamWriter file = new System.IO.StreamWriter(C1Upload1.TargetPhysicalFolder+"\Debug.txt", true))
    {
    file.WriteLine(DateTime.Now.ToString()+"{tab}"+LogEntry);
    }
    using (System.IO.StreamWriter file = new System.IO.StreamWriter(C1Upload1.TempFolder+"\Debug.txt", true))
    {
    file.WriteLine(DateTime.Now.ToString() + "{tab}" + LogEntry);
    }
    }


    void C1Upload1_ValidatingFile(object sender, C1.Web.UI.Controls.C1Upload.ValidateFileEventArgs e)
    {
    WriteLog("C1Upload1_ValidatingFile");
    }

    yeilds nothing in debug.txt
  • Replied 10 September 2017, 11:40 am EST

    Hello,

    Yes, we need to make some changes in the web.config file for IIS7 and here the details for same :


    <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>

    <modules runAllManagedModulesForAllRequests="true">
    <add name="C1UploadModule" type="C1.Web.UI.Controls.C1Upload.UploadModule,C1.Web.UI.Controls.4"/>
    </modules>

    <handlers>
    <add name="C1Upload" path="C1UploadProgress.axd" verb="*" type="C1.Web.UI.Controls.C1Upload.UploadProgressHandler,C1.Web.UI.Controls.4"/>
    </handlers>
    </system.webServer>


    I have created a sample with above modifications and it works fine in IIS7 at my end. Kindly check the attached sample and let me know your observations.

    Regards
    Ashish
    2012/01/C1Upload.zip
  • Replied 10 September 2017, 11:40 am EST

    Hello,

    I tried to replicate the issue but it works fine at my end i.e. upload works properly and validating event also fires. Please check the attached sample("C1Upload_Issue") and let me know your observations. If it works well, then modify its code so that it reproduces the issue.

    I tested it with the latest build of WebUI which is available at the following link: http://prerelease.componentone.com/dotnet20/C1WebUI/2011-T2/

    Regards
    Ashish
    2011/07/C1Upload_Issue.zip
  • Replied 10 September 2017, 11:40 am EST

    This line causes a 500 error to occur:
    <validation validateIntegratedModeConfiguration="false"/>


    Without that line it still doesn't work and I see this in the log
    Log Name:      Application
    Source: ASP.NET 4.0.30319.0
    Date: 1/12/2012 4:24:51 AM
    Event ID: 1309
    Task Category: Web Event
    Level: Warning
    Keywords: Classic
    User: N/A
    Description:
    Event code: 3005
    Event message: An unhandled exception has occurred.
    Event time: 1/12/2012 4:24:51 AM
    Event time (UTC): 1/12/2012 12:24:51 PM
    Event ID: a6edd754fa364209a9f5b3b5e75e9bee
    Event sequence: 76
    Event occurrence: 1
    Event detail code: 0

    Application information:

    Trust level: Full
    Application Virtual Path: /


    Process information:
    Process ID: 2148
    Process name: w3wp.exe


    Exception information:
    Exception type: HttpException
    Exception message: Server cannot append header after HTTP headers have been sent.
    at System.Web.HttpResponse.AppendHeader(String name, String value)
    at Blackbaud.Web.Content.Portal.BBPage.OnPreRender(EventArgs e)
    at System.Web.UI.Control.PreRenderRecursiveInternal()
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Thread information:
    Thread ID: 99

    Is impersonating: False
    Stack trace: at System.Web.HttpResponse.AppendHeader(String name, String value)
    at Blackbaud.Web.Content.Portal.BBPage.OnPreRender(EventArgs e)
    at System.Web.UI.Control.PreRenderRecursiveInternal()
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


  • Replied 10 September 2017, 11:40 am EST

    Hello,

    Kindly make sure that you have set the Application pool as ASP.NET v4.0 in the IIS. If you have already set, then I would request you to post a small sample replicating the issue so that I can check at my end and can provide you further help.

    Regards
    Ashish
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels