Asposeを使用してWord文書を生成します。サーバーから戻ってきたときに、ブラウザで自動的に開く必要があります。
これが私のコードです:
ドキュメントを取得するためにAjax呼び出しを実行します
$.ajax({
url: "Export/StreamWord",
data: { topicId: CurrentTopic.id },
success: function (result) {
//Nothing here. I think that the browser must open the file automatically.
}
});
Controller .NET MVC 3
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult StreamWord(string topicId)
{
var stream = new MemoryStream();
Document doc = exportRepos.GenerateWord(topicId); //Document is a Aspose object
doc.Save(stream, SaveFormat.Docx);
stream.WriteTo(Response.OutputStream);
return File(stream, "application/doc", "test.doc");
}
しかし、ブラウザから実行しても何も起こりません。画像で確認できるサーバーからの応答。ドキュメントが来ますが、開かれていません。
助言がありますか?