viernes, 17 de octubre de 2014

KENDO UPLOAD FINAL WEB CONFIG

intro
http://docs.telerik.com/kendo-ui/web/upload/modes#asynchronous-mode
--------------------------------------------------------
http://stackoverflow.com/questions/24105556/large-file-in-kendo-ui-uploader
http://stackoverflow.com/questions/19421829/how-to-upload-a-file-with-kendo-uploader-and-using-ajax-request
http://blogs.visoftinc.com/2013/02/25/kendo-ui-upload-control-with-existing-files/
http://www.strathweb.com/2012/09/dealing-with-large-files-in-asp-net-web-api/
**********************************************************
http://www.codeproject.com/Articles/46745/Upload-files-using-an-HttpHandler
You can increase the file size being uploaded by adding the following to your web.config. TheexecutionTimeout is in seconds, and maxRequestLength is in bytes.
***************************************************

CONFIGURACION DE TELERIK
http://www.telerik.com/help/aspnet-ajax/upload-uploading-large-files.html


http://stackoverflow.com/questions/1690337/what-is-the-best-practice-for-storing-a-file-upload-to-a-memorystream-c
-------------------------------------------------------------------------------------------------------------------------
http://stackoverflow.com/questions/288612/how-to-increase-the-max-upload-file-size-in-asp-net
This setting goes in your web.config file. It affects the entire application, though... I don't think you can set it per page.
<configuration>
  <system.web>
    <httpRuntime maxRequestLength="xxx" />
  </system.web>
</configuration>
"xxx" is in KB. The default is 4096 (= 4 MB).
*****************
Upload.aspx.cs

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.Web.Script.Serialization;

namespace SCPServicio.admin
{
    public partial class Upload : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ProcessRequest();
        }

        public void ProcessRequest()
        {
            Response.Expires = -1;
            try
            {
                string formatdate = "yyyy_MM_dd";
                HttpPostedFile postedFile = Request.Files["files"];
                string savepath = Server.MapPath("fileupload/");
                string filename = DateTime.Now.ToString(formatdate) + "_" + Path.GetFileName(postedFile.FileName);
                if (!Directory.Exists(savepath))
                    Directory.CreateDirectory(savepath);
                postedFile.SaveAs(savepath + filename);

                Response.Clear();
                HttpContext.Current.Response.Flush(); // Sends all currently buffered output to the client.
                HttpContext.Current.Response.SuppressContent = true;  // Gets or sets a value indicating whether to send HTTP content to the client.
                HttpContext.Current.ApplicationInstance.CompleteRequest(); // Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event.
              
                //arreglo parcial de System.Threading.ThreadAbortException: Thread was being aborted.
                //http://stackoverflow.com/questions/20988445/how-to-avoid-response-end-thread-was-being-aborted-exception-during-the-exce
                //http://stackoverflow.com/questions/62154/response-clear-in-asp-net-3-5
               //upload              
               //http://stackoverflow.com/questions/19254998/clearing-a-response-in-postback-to-download-text-file-from-button-click

            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());

            }
        }
    }
}
*************************
SubirArchivo.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Layout.Master" AutoEventWireup="true" CodeBehind="SubirArchivo.aspx.cs" Inherits="SCPServicio.admin.SubirArchivo" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="SidebarContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<div class="container-fluid">
    <div class="row-fluid">
        <div class=" offset6 span6">
            <div class="form-horizontal labels-forms">
                <div class="control-group">                            
                    <div class="controls">
                        <input name="files" id="archivoUploader"  type="file" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row-fluid">
    <div id="gridListaItems">
    </div>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ScriptsContent" runat="server">
<script>
    $("#archivoUploader").kendoUpload({
        async: {
            saveUrl: "Upload.aspx",
            autoUpload: true
        },
        success: function (e) {
            var filename = e.files[0].name;
            alert("archivo subido correctamente");
        },
        error: function (e) {
            alert("archivo subido correctamente");
        }
    });
</script>
</asp:Content>
****************
web.config
...
    <sessionState timeout="40"></sessionState>
    <httpRuntime maxRequestLength="702400" executionTimeout="3600" />
    
    <!--<httpRuntime maxRequestLength="102400" executionTimeout="3600" />-->
    



  </system.web>
...

No hay comentarios:

Publicar un comentario