代码之家  ›  专栏  ›  技术社区  ›  exlnt

AspNetZero-用户索引视图缩略图问题

  •  0
  • exlnt  · 技术社区  · 6 年前

    我复制了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应用程序中,两个控制器都是同一个区域的一部分。

    1 回复  |  直到 6 年前
        1
  •  0
  •   exlnt    6 年前

    解决了的 用户照片功能正在点击 而不是区域内的那个。 在我的例子中,我不得不像对待我所在区域的所有情态动词和脚本一样对待URL。 这是你的名字 成功了。

    var empPhotoUrl = abp.appPath + 'AreaName/Employee/GetProfilePictureById?id=';