Content-Disposition

Nov 25, 2010 at 11:20 AM

I would like to be able to choose a value of Сontent-Disposition.

ResumableDownloadResult.cs

if (!string.IsNullOrEmpty(ResumableRequest.FileName))
{
  context.HttpContext.Response.AddHeader(
    "Content-Disposition", string.Format("inline; filename=\"{0}\"", ResumableRequest.FileName));
}

Nov 25, 2010 at 6:12 PM

This is good feedback. I hadn't thought this would be something people would want to configure. I'm happy to be wrong!

Please tell me what you think would be the best way to support this? Would you want to specify this as part of the response line?

return new ResumableFileResult(ResumableRequest, contentFile, dispositionValue);

Should I accept a dictionary that has header names and values to override the defaults?

return new ResumableFileResult(ResumableRequest, contentFile, headerOverrides);

Should these be rolled into the ResumableDownloadRequest object?

ResumableRequest.ContentDisposition = "some override value";
return new ResumableFileResult(ResumableRequest, contentFile);

If I roll the extra headers into the ResumableDownloadRequest then it makes it easier to subclass and roll these values into a custom class to set these values and keep the controller clean. I think this might be the best solution but I want to ensure it will do what you want.

Nov 26, 2010 at 4:36 AM

Well. I think, the best way would be to override ResumableFileResult constructor. It would to apply an object, that implements header.

For example, object {int index, string value}. Index is HttpWorkerRequest header constant.

It will be in .net traditions, imho.

Nov 26, 2010 at 4:38 AM

Сorrection: IEnumerable of header objects.

Nov 26, 2010 at 3:43 PM

Because the ResumableDownloadResult is the base class where all the work is done, the overridden constructor would have to be placed there so the output could be written. Then every class that inherits from the base should also offer the additional constructor as well. While it wouldn't be terribly difficult to do I'm concerned about the additional complexity.

Another alternative could be to just subclass the result you want, ResumableFileResult in this case, and override the WriteCommonHeaders method. This would give you full control over all the headers to be written to the output.

I will take another look this weekend and see what I can do to make the project more open to additional settings without getting cumbersome to implement for simple cases.

Jun 25, 2011 at 3:39 AM

I am horribly sorry for the slow response. I've been trying to find ways for months to clean this project up and bring it in line with how similar actions work in ASP.NET MVC.

Unfortunately I could find no way to get there while maintaining backward compatibility. I'm not sure maintaining compatibility would be desired but I honestly have no idea how people use this project. So for the time being I'm retiring this project in favor of one I just wrote from nearly scratch. The codebase borrows heavily from this project but it removes a lot of moving pieces that cluttered things up. The new ResumingFileResults use the same signature style as the MVC2 FileResult actions. This means ContentType is right there in the constructor call for you.

Please check out the new project if you still have these needs. It's much easier to use and understand though I do need to update the source comments a bit!

If you're a NuGet user, the new project is also available in the main feed.

-Erik