We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

MVC Application will not let me save file- works in other application with identical code

I need to save a workbook in a MVC C# application that I’ve been working on.

I’m using the following code,



workbook.Save(this.Response, “Report.xls”, ContentDisposition.Inline, new XlsSaveOptions());


And it works perfectly in the application I originally developed, but after moving the code over into the MVC project it needs to be in, I’m getting errors.
Both have the same code, the same data, the same using statements and assembly references, and yet it works perfectly in the original, but in the MVC application the whole line of code is underlined in red and it says
"The best overloaded method match for ‘Aspose.Cells.Workbook.Save(System.Web.HttpResponse, string, Aspose.Cells.ContentDisposition, Aspose.Cells.SaveOptions)’ has some invalid arguments".

I would appreciate any help in resolving this issue, either in fixing this error or pursuing an alternate method for streaming the file to the end-user.

Hi,


I think you should use fully qualified naming when using the APIs of the component. Could you try to change the line of code to:
e.g
Sample code:

workbook.Save(this.Response, “Report.xls”, Aspose.Cells.ContentDisposition.Inline, new Aspose.Cells.XlsSaveOptions());

Let us know if you still find the issue.

Thank you.

I have made the suggested changes, but the error has not changed.

Hi,

It looks like you might be using Aspose.Cells.dll .NET Frame Client Profile version in, e.g "..\Bin\net3.5_ClientProfile". This version is used for console applications mainly. Please use the .NET2.0 compiled version of Aspose.Cells from "....\Bin\net2.0" which is there for all types of desktop and web applications/projects for .NET frameworks like 2.0, 3.0, 3.5, 4.x etc.

Thanks,

I’m afraid that’s not the solution either. I am using the .NET2.0 version of Aspose Cells. I appreciate your prompt assistance on this matter however.

I have solved my issue.

Apparently in MVC applications “this.Response” is a HttpResponseBase type, rather than a HttpResponse type, which was causing the error.
Replacing ‘this.Response’ with ‘System.Web.HttpContext.Current.Response’ solved the problem, and my code now works as it should.
Thank you again for your help in this matter.

Hi,


Good to know that you have figured it out now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.