Aug 01, 2011, 5:09 PM
[CLOSED] Download file in MVC have error
Hi:
I have a issue about downloading file in MVC.
In my page, I have a form named "fileform" the markup is:
the method "exportExcel" is like this:
The error message is about like
Could you help sort out this problem please?
Thank you
I have a issue about downloading file in MVC.
In my page, I have a form named "fileform" the markup is:
<form id="fileform" class="x-hide-display">
</form>
I also have a button with a client click handler:<ext:Button ID="BtnExportExcel" runat="server" Text="<%$Resources:Strings,ExportExcel%>">
<Listeners>
<Click Fn="exportExcel"></Click>
</Listeners>
</ext:Button>
On Javascript filethe method "exportExcel" is like this:
var exportExcel= function () {
Ext.net.DirectMethod.request({
url: $shell.resolveUrl("~/Planning/CorePlanning/ExportExcel"),
isUpload: true,
formProxyArg: "downloadForm",
buffer: 300,
cleanRequest: true,
params: {
titles: "TestValue",
options: "TestValue"
},
success: function(result) {
//Success process.....//
},
failure: function(msg, response) {
//Failure process.....//
}
});
}
In the controller, the method which is called is:public AjaxResult ExportExcel(string titles, string options)
{
AjaxResult result = new AjaxResult();
result.IsUpload = true;
using (var memoryStream = new MemoryStream())
{
//....................
//Create the content for memoryStream
Response.AddHeader("Content-Disposition",
string.Format("attachment; filename=test.xsl"));
result.Result=File(memoryStream.ToArray(), "application/vnd.ms-excel");
}
return result;
}
Now when I click the button I got a internal error which is code 500.The error message is about like
A potentially dangerous Request.Form value was detected from the client (titles="...tem &nbsp;<button type=\"butto...").
Thank you
Last edited by Daniil; Aug 02, 2011 at 1:01 PM.
Reason: [CLOSED]