Widget with link to remote document

Idea Lab

Idea Lab
Be part of Telligent's future of firsts. Explore forums, blogs, and documents focusing on community strategy and improvements to community and collaboration software.

Widget with link to remote document

This question has suggested answer(s)

Hi, 

I'm tring to create simple widget with link to remote document:

<%@ Control Language="C#" AutoEventWireup="true" %>

<%@ Import Namespace="System.Net"%>

<%@ Import Namespace="System.IO"%>

<script runat="server" language="C#">

        protected void LinkButton1_Click(object sender, EventArgs e)

        {

                    string username = "UserName";

                    string userpassword = "Pass";

                    string domain = "Domain";

                    NetworkCredential networkCredential = new NetworkCredential(username, userpassword, domain);

                    WebClient webClient = new WebClient();

                    webClient.Credentials = networkCredential;

                    Byte[] buffer = webClient.DownloadData("http://localhost/Docs/Documents/1.jpg");

 

                    MemoryStream memoryStream = new MemoryStream(buffer);

                    Response.Clear();

                    Response.ContentType = "application/octet-stream";

                    Response.AddHeader("Content-Disposition", "attachment; filename=" + "1.jpg");

                    memoryStream.WriteTo(Response.OutputStream);

                    Response.End();

        }

</script>

<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">LinkButton</asp:LinkButton>

 

But filesize is incorrect (remote filesize: 22kb ,when downloaded from widget: 40kb). This problem didn't depend on file.

What's wrong?

 

Thanks

Verified Answer
  • Since this is in custom code rather than in the product, there isn't much we can do.  You would likely need to compare the original and the downloaded file and track down why your code is downloading it incorrectly.

All Replies
  • Since this is in custom code rather than in the product, there isn't much we can do.  You would likely need to compare the original and the downloaded file and track down why your code is downloading it incorrectly.