在MVC视图中检索和显示文档 [英] Retrieving and Displaying Documents in MVC View

查看:62
本文介绍了在MVC视图中检索和显示文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在asp.net MVC 5 EF 6.1中开发应用程序,并将文档作为字节上传到SQL Server数据库.我的上传效果很好,现在我想在视图中检索和显示文档,以便用户可以单击它以查看或查看文档 在另一个窗口中.到目前为止,我没有成功.我使用的代码要求保存文件,但这不是我想要的.任何帮助将不胜感激
 
公共ActionResult索引(int id = ContractIdtxt)
{
var fileToRetrieve = Db.Documents.Find(ContractIdtxt);
返回File(fileToRetrieve.DocumentContent,fileToRetrieve.DocumentName,fileToRetrieve.DocumentType);
//Db.Documents中的p中的var record =来自p
//其中p.ContractId == ContractIdtxt
//选择p;
//返回视图(记录);
}


Ebenezer



I am developing an application in asp.net MVC 5 EF 6.1 and  uploading documents to a SQL Server database as bytes. My uploads works fine and now I want to retrieve and display the documents in a View so users can click on it to down or view the document in a different window. So far I am not succeeding. The code I am using is asking to save the file but that is not what I want. Any help will be appreciated
 
public ActionResult Index(int id = ContractIdtxt)
{
var fileToRetrieve = Db.Documents.Find(ContractIdtxt);
return File(fileToRetrieve.DocumentContent, fileToRetrieve.DocumentName, fileToRetrieve.DocumentType);
//var record = from p in Db.Documents
// where p.ContractId == ContractIdtxt
// select p;
//return View(record);
}


Ebenezer

推荐答案

请在 asp.net MVC论坛以获得更好的帮助.
Please post your question at asp.net MVC forum for a better assistance.


这篇关于在MVC视图中检索和显示文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆