M
Matthew Trunnell
Hi everyone,
I'm implementing the HTTP 206 Partial Content spec. This
requires an additional header of the form:
"Content-Range: xxx-yyy/zzz"
See http://www.w3.org/Protocols/rfc2616/rfc2616-
sec14.html#sec14.16
However, when I call the Response.AddHeader() method, I
get an exception throw from the private method
HttpResponse.ValidateFileRange(). The exception
is "Specified range is not valid"
There is virtually *nothing* on the web about the
ValidateFileRange() method-- it's marked private and not
part of the MSDN documentation.
The offending code:
Response.Clear();
Response.ClearHeaders();
Response.StatusCode = 206;
Response.StatusDescription = "Partial Content";
Response.AppendHeader("Content-Length",Convert.ToString
(endPosition-startPosition+1));
Response.AppendHeader("Content-
Range","bytes "+Convert.ToString(startPosition)+"-
"+Convert.ToString(endPosition)+"/"+Convert.ToString
(fileSize));
There's also a later call to the WriteFile(), which makes
more sense to call some private method like
ValidateFileRange(), except that the program never gets
there:
Response.WriteFile
(@filePath+@fileName,startPosition,fileSize);
Here the stack trace:
at System.Web.HttpResponse.ValidateFileRange(String
filename, Int64 offset, Int64 length)\r\n
at System.Web.HttpResponse.WriteFile(String filename,
Int64 offset, Int64 size)\r\n
at Client.Webapplication.securefile2.DoSegmentedDownload
(ArrayList requestRanges, Int64 fileSize, String fileName,
String filePath) in f:\\projects\\[snip]
\\securefile2.aspx.cs:line 161\r\n
at Client.Webapplication.securefile2.Page_Load(Object
sender, EventArgs e) in f:\\projects\\[snip]
\\securefile2.aspx.cs:line 77
Any help or pointers would be greatly appreciated!
Matt
I'm implementing the HTTP 206 Partial Content spec. This
requires an additional header of the form:
"Content-Range: xxx-yyy/zzz"
See http://www.w3.org/Protocols/rfc2616/rfc2616-
sec14.html#sec14.16
However, when I call the Response.AddHeader() method, I
get an exception throw from the private method
HttpResponse.ValidateFileRange(). The exception
is "Specified range is not valid"
There is virtually *nothing* on the web about the
ValidateFileRange() method-- it's marked private and not
part of the MSDN documentation.
The offending code:
Response.Clear();
Response.ClearHeaders();
Response.StatusCode = 206;
Response.StatusDescription = "Partial Content";
Response.AppendHeader("Content-Length",Convert.ToString
(endPosition-startPosition+1));
Response.AppendHeader("Content-
Range","bytes "+Convert.ToString(startPosition)+"-
"+Convert.ToString(endPosition)+"/"+Convert.ToString
(fileSize));
There's also a later call to the WriteFile(), which makes
more sense to call some private method like
ValidateFileRange(), except that the program never gets
there:
Response.WriteFile
(@filePath+@fileName,startPosition,fileSize);
Here the stack trace:
at System.Web.HttpResponse.ValidateFileRange(String
filename, Int64 offset, Int64 length)\r\n
at System.Web.HttpResponse.WriteFile(String filename,
Int64 offset, Int64 size)\r\n
at Client.Webapplication.securefile2.DoSegmentedDownload
(ArrayList requestRanges, Int64 fileSize, String fileName,
String filePath) in f:\\projects\\[snip]
\\securefile2.aspx.cs:line 161\r\n
at Client.Webapplication.securefile2.Page_Load(Object
sender, EventArgs e) in f:\\projects\\[snip]
\\securefile2.aspx.cs:line 77
Any help or pointers would be greatly appreciated!
Matt