我复制了AspNetZero解决方案中用于“profile picture”功能的所有代码。我指的是允许用户上传自己照片的功能。
上传图像并保存到binary objects表中一切正常。
当我试图在employee index view datatable列中显示上传照片的缩略图时,就会出现这个问题。我从解决方案中的用户索引视图复制了此功能。
下面是在
用户
索引视图:
targets: 1,
data: "userName",
render: function (userName, type, row, meta) {
var $container = $("<span/>");
if (row.profilePictureId) {
var profilePictureUrl = "/Profile/GetProfilePicture?t=" + row.profilePictureId;
var $link = $("<a/>").attr("href", profilePictureUrl).attr("target", "_blank");
var $img = $("<img/>")
.addClass("img-circle")
.attr("src", profilePictureUrl);
$link.append($img);
$container.append($link);
}
$container.append(userName);
return $container[0].outerHTML;
}
我的电脑里有同样的代码
雇员
索引视图:
targets: 4,
orderable: true,
autoWidth: true,
data: "fullName",
render: function(fullName, type, row, meta) {
var $container = $("<span/>");
if (row.employeePictureId) {
var profilePictureUrl = "/Employee/GetProfilePictureById?id=" + row.employeePictureId;
var $link = $("<a/>").attr("href", profilePictureUrl).attr("target", "_blank");
var $img = $("<img/>").addClass("img-circle").attr("src", profilePictureUrl);
$link.append($img);
$container.append($link);
}
$container.append(fullName);
return $container[0].outerHTML;
}
var profilePictureUrl = "/Employee/GetProfilePictureById?id=" + row.employeePictureId;
如果我用user index.js中的行替换上面的行并调用profile controller方法,它就可以正常工作。但是当我尝试调用employee controller方法时,它总是抛出404错误。
在我的解决方案中,我的员工控制器与概要文件控制器处于同一级别。在我的MVC应用程序中,两个控制器都是同一个区域的一部分。