I have a method where I am trying to save the workbook with custom properties. I am using the workbook.Save() to achieve it.
After updating to .NET 8, I am getting the following error for workbook Save methods. The type or namespace name ‘ContentDisposition’ does not exist in the namespace ‘Aspose.Cells’ (are you missing an assembly reference?)
Code to save workbook:
public static void SaveWithSensitivity(
Aspose.Cells.Workbook workbook,
HttpResponse response,
string fileName,
Aspose.Cells.ContentDisposition contentDisposition,
Aspose.Cells.SaveOptions saveOptions,
bool enableHttpCompression
) {
workbook.CustomDocumentProperties.Add(“Label_Name”,“Sensitive_Label”)
workbook.CustomDocumentProperties.Add(“Label_Type”,“Sensitive”)
workbook.Save(response, fileName, contentDisposition, saveOptions, enableHttpCompression);
}
It appears you are experiencing issues after upgrading to .NET 8 and Aspose 25.9.0. The error regarding ContentDisposition not existing in the Aspose.Cells namespace suggests that this class may have been removed or renamed in the new version.
For the Save method of the Workbook class, ensure that you are using the correct overloads available in the updated version. You may need to consult the latest documentation for any changes in method signatures.
Regarding the Document.Save method, the error indicates that the overload you are trying to use is no longer available. Please verify the available overloads in the updated Aspose.Words documentation.
Here’s a minimal example of how you might adjust your code:
public static void SaveWithSensitivity(
Aspose.Cells.Workbook workbook,
HttpResponse response,
string fileName,
Aspose.Cells.SaveOptions saveOptions
) {
workbook.CustomDocumentProperties.Add("Label_Name", "Sensitive_Label");
workbook.CustomDocumentProperties.Add("Label_Type", "Sensitive");
workbook.Save(response, fileName, saveOptions); // Ensure this matches the available overloads
}
public static void SaveWithSensitivity(
Aspose.Words.Document document,
HttpResponse response,
string fileName,
Aspose.Words.Saving.SaveOptions saveOptions
) {
document.CustomDocumentProperties.Add("Label_Name", "Sensitive_Label");
document.CustomDocumentProperties.Add("Label_Type", "Sensitive");
document.Save(response, fileName, saveOptions); // Ensure this matches the available overloads
}
Make sure to check the Aspose documentation for the latest changes in method signatures and available classes. If you are working with a text file, consider using a render-stage approach instead of relying on document properties or save options that may not apply.
Please note, the System.Web.HttpResponse class, part of the System.Web namespace, is a component of the .NET Framework and is primarily used in traditional ASP.NET applications. It is not directly available in .NET 8.0 or other versions of .NET Core/.NET (>= .NET 5+). That’s why, the relevant overloads in Aspose.Cells for .NET8.0 assemblies are not there. Please refer to the following code to save the file to the stream, then do operation to the stream as required for your reference. Saving File to Response Object|Documentation
Regarding issue in Aspose.Words, please post your query in relevant forum category.
There are two options to chose in ContentDisposition, Attachment or Inline. This works for ContentDisposition : Attachment. How to achieve ContentDisposition : Inline? How to achieve both?
Is it possible to leverage HttpResponse from Microsoft.AspNetCore.Http namespace to achieve it. Can you provide an example on this scenario.