[CLOSED] [1.0] File download in MVC
Hi,
I try to do a file download, but I always receive "Request Error".
Here is my button definition:
Code:
<ext:Button runat="server" Text="Click Me">
<DirectEvents>
<Click Url="~/Home/OnClicked" IsUpload="true" />
</DirectEvents>
</ext:Button>
and the controller method is equally simple:
Code:
public ActionResult OnClicked()
{
return new FileContentResult( Encoding.UTF8.GetBytes( "testing" ), MediaTypeNames.Text.Plain );
}
Is it supported?
Thanks,
Tadeusz
RE: [CLOSED] [1.0] File download in MVC
Hi,
IsUpload works if from presented only. Therefore you should wrap the button by form
Code:
<form>
<ext:Button runat="server" Text="Click Me">
<DirectEvents>
<Click Url="/Data/OnClicked" IsUpload="true" />
</DirectEvents>
</ext:Button>
</form>
It works fine for FF and Chrome but IE as always works differently. It still try to open content in the page (instead to show save file dialog) therefore it is need to use none-standard content-type
Code:
public ActionResult OnClicked()
{
return new FileContentResult(Encoding.UTF8.GetBytes("testing"), "text/text");
}
RE: [CLOSED] [1.0] File download in MVC
Thanks a lot!
Regards,
Tadeusz