要求是显示所有文档的缩略图,如pdf和ms-words,我们将文档存储在数据库中,我们需要将其转换为文件流,并且必须显示为缩略图.
截至目前,我能够显示图像,因为它是直接的,同样我将必须显示pdf和word文档的图像.我将展示我如何为图像做
控制器:
public ActionResult File(int id)
{
var fileToRetrieve = db.File.Find(id);
return File(fileToRetrieve.Content, fileToRetrieve.ContentType);
}
Run Code Online (Sandbox Code Playgroud)
视图:
@foreach (var item in Model)
{
<div class="form-group">
<img src="~/Home/File?id=@item.FileId" alt="avatar" width="100px" height="100x" />
</div>
}
Run Code Online (Sandbox Code Playgroud) 我现在正在努力工作.我可能不会很好地解释,但我已经理解,我想对我的理解相同.
我正在使用基于Owin令牌的web api身份验证,登录我正在调用返回访问令牌的令牌方法.我想知道如何保护我们的web api,这样没有访问令牌就不应该允许调用web api方法.我正在使用角度js资源,我相信我们需要在angularjs服务部分定义标题,但我在哪里以及如何完全没有任何想法,任何人都可以请帮助我.
例:-
这是我用angularjs写的服务,
sghServices.factory('GlobalSettingsService', function ($resource) {
return $resource("../Api/eClaim/SecondGlobalSettings",
{},
{
post: {
method: 'POST', isArray: false,
headers: { 'Content-Type': 'application/json' }
},
update: {
method: 'PUT'
}
});
});
Run Code Online (Sandbox Code Playgroud)
这是web api方法
[Authorize]
[Route("~/Api/eClaim/GlobalSettings")]
[HttpGet]
public ReportAndeCliam GetGlobalSettings()
{
//Code Wriiten here
}
Run Code Online (Sandbox Code Playgroud)
截至目前我能够访问没有访问令牌的web api,我想以这种方式设计如果令牌不可用,它不应该允许使用[授权] web api方法.
提前致谢 :)
asp.net-mvc angularjs single-page-application asp.net-web-api2