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

Success response from C#

1 Answer 91 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Erick
Top achievements
Rank 1
Erick asked on 24 Sep 2013, 09:38 PM
Hi

I'm trying to use the kendo upload web control with C#, I can upload the controls is always on error, I know that I have to return an empty response but I don't know exactly how. This is my javascript

<script>
            $(document).ready(function () {
                $("#files").kendoUpload({
                    async: {
                        saveUrl: "Attachments.aspx",
                        removeUrl: "remove",
                        autoUpload: true
                    }
                });
            });
        </script>

and on C# I have

protected void Page_Load(object sender, EventArgs e)
    {
        HttpFileCollection x = Request.Files;

        if (x.Count>0)
        {
            Response.Clear();
            Response.ContentType = "application/json";
            Response.Write("{}"); 
        }
    }

I tried with Response.Write("") to with and without contentype but it didn't work.

Do anyone know how to build the correct success response?

1 Answer, 1 is accepted

Sort by
0
Erick
Top achievements
Rank 1
answered on 24 Sep 2013, 11:55 PM
I finally found my solution

I was using Response.clear() on the load event of my aspx page, so at the end the response had all the html for that page because it was rendered anyway, so I built a different page to use as response and overwrote the render method with an empty method and that did the trick, this is the C# code

Main page (the one with the upload control, that in my case I am using it to retrieve the files too)
protected void Page_Load(object sender, EventArgs e)
        {
            HttpFileCollection x = Request.Files;
           
            if (x.Count > 0)
            {
                    //code to retrive the files
                    Server.TransferRequest("Response.aspx");
            }
        }


Response.aspx.cs

protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected override void Render(HtmlTextWriter output)
        {
        }
Tags
Upload
Asked by
Erick
Top achievements
Rank 1
Answers by
Erick
Top achievements
Rank 1
Share this question
or