Click here to Skip to main content
15,909,897 members
Home / Discussions / C#
   

C#

 
GeneralRe: Im trying to make a custom installer of some sort.... Pin
lekira21-Nov-08 19:20
lekira21-Nov-08 19:20 
GeneralRe: Im trying to make a custom installer of some sort.... Pin
Mycroft Holmes21-Nov-08 21:32
professionalMycroft Holmes21-Nov-08 21:32 
GeneralRe: Im trying to make a custom installer of some sort.... Pin
lekira23-Nov-08 13:54
lekira23-Nov-08 13:54 
GeneralRe: Im trying to make a custom installer of some sort.... Pin
Mycroft Holmes23-Nov-08 14:14
professionalMycroft Holmes23-Nov-08 14:14 
GeneralRe: Im trying to make a custom installer of some sort.... Pin
Dave Kreskowiak24-Nov-08 16:35
mveDave Kreskowiak24-Nov-08 16:35 
GeneralRe: Im trying to make a custom installer of some sort.... Pin
Dave Kreskowiak22-Nov-08 4:20
mveDave Kreskowiak22-Nov-08 4:20 
GeneralRe: Im trying to make a custom installer of some sort.... Pin
lekira23-Nov-08 13:57
lekira23-Nov-08 13:57 
QuestionErrors in http data stream from ASP.NET server download Pin
qwe123421-Nov-08 12:54
qwe123421-Nov-08 12:54 
Hello,

I'm trying to implement a client server system that will download a file(as a byte[] array trough a stream) from an ASP.NET server. I'm getting the file on chunks because as reported in many other places the server Respond.WriteFile and Response.TransmitFile are not reliable solutions for sending big files.

The problem is that when I run the server on local machine to test my system it works very good but when I test it on the site the clients receives every time in a few places in the stream also an array of zero's (about 1000 but not the same length every time) that are being randomly placed between the valid data. Since this happens only on a remote connection I'm thinking that data is being altered during transmition.

Should I check the data being transffered trough a system taht validates it like a checksum for every chunck sent and request that part again if it's invalid or there is another solution to this.

the server code:

int bufferLength = 2048;

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

Response.AddHeader("Content-Disposition", "attachment; filename=" + Request["document"]);

Response.AddHeader("Content-length", bytes.Length.ToString());

for (int i = 0; i < bytes.Length; i += bufferLength)
{
    // Verify that the client is connected.
    if (Response.IsClientConnected)
    {
        // Write the data to the current output stream.
        if (i + bufferLength < bytes.Length)
            Response.OutputStream.Write(bytes, i, bufferLength);
        else
            Response.OutputStream.Write(bytes, i, bytes.Length - i);

        // Flush the data to the HTML output.
        Response.Flush();
    }
    else
    {
        //prevent infinite loop if user disconnects
        break;
    }
}

Response.Close();





client source:


HttpWebRequest request = (HttpWebRequest)WebRequest.Create("");

 request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";

 HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse();
 response = webResponse.GetResponseStream();

 bytes =  new byte[Convert.ToInt32(webResponse.Headers["Content-length"])];


 for (int i = 0; i < bytes.Length; i += AppContext.BufferLength)
 {
         try
         {

             if (i + AppContext.BufferLength > bytes.Length)
                 response.Read(bytes, i, bytes.Length - i);
             else
                 response.Read(bytes, i, AppContext.BufferLength);
             if (i + AppContext.BufferLength > bytes.Length)
                 control.ReportProgress(i + AppContext.BufferLength, bytes.Length - i);
             else
                 control.ReportProgress(i + AppContext.BufferLength, bytes.Length);

         }
         catch (Exception ex) //-
         {
             exception = ex.Message;
         }

 }

 response.Close();

AnswerRe: Errors in http data stream from ASP.NET server download Pin
Guffa21-Nov-08 15:06
Guffa21-Nov-08 15:06 
QuestionRename file Pin
netJP12L21-Nov-08 11:35
netJP12L21-Nov-08 11:35 
AnswerRe: Rename file Pin
Mycroft Holmes21-Nov-08 13:25
professionalMycroft Holmes21-Nov-08 13:25 
GeneralRe: Rename file Pin
netJP12L22-Nov-08 5:22
netJP12L22-Nov-08 5:22 
GeneralRe: Rename file Pin
Mycroft Holmes22-Nov-08 14:39
professionalMycroft Holmes22-Nov-08 14:39 
AnswerRe: Rename file Pin
Thomas Stockwell21-Nov-08 15:32
professionalThomas Stockwell21-Nov-08 15:32 
AnswerRe: Rename file Pin
Dave Kreskowiak21-Nov-08 18:57
mveDave Kreskowiak21-Nov-08 18:57 
QuestionPowerful Chart Control ? Pin
stancrm21-Nov-08 11:22
stancrm21-Nov-08 11:22 
AnswerRe: Powerful Chart Control ? Pin
Mycroft Holmes21-Nov-08 13:29
professionalMycroft Holmes21-Nov-08 13:29 
GeneralRe: Powerful Chart Control ? Pin
Dr.Walt Fair, PE22-Nov-08 10:27
professionalDr.Walt Fair, PE22-Nov-08 10:27 
GeneralRe: Powerful Chart Control ? Pin
Mycroft Holmes22-Nov-08 14:46
professionalMycroft Holmes22-Nov-08 14:46 
GeneralRe: Powerful Chart Control ? Pin
Dr.Walt Fair, PE22-Nov-08 14:58
professionalDr.Walt Fair, PE22-Nov-08 14:58 
GeneralRe: Powerful Chart Control ? Pin
Mycroft Holmes22-Nov-08 15:50
professionalMycroft Holmes22-Nov-08 15:50 
GeneralRe: Powerful Chart Control ? Pin
Dr.Walt Fair, PE22-Nov-08 16:53
professionalDr.Walt Fair, PE22-Nov-08 16:53 
GeneralRe: Powerful Chart Control ? Pin
Mark Churchill23-Nov-08 12:35
Mark Churchill23-Nov-08 12:35 
AnswerRe: Powerful Chart Control ? Pin
Dave Kreskowiak21-Nov-08 18:52
mveDave Kreskowiak21-Nov-08 18:52 
GeneralRe: Powerful Chart Control ? Pin
stancrm22-Nov-08 0:25
stancrm22-Nov-08 0:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.