HttpResponse.ValidateFileRange()

  • Thread starter Matthew Trunnell
  • Start date
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top