首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Backload和-不正确显示上传的文件

Backload和-不正确显示上传的文件
EN

Stack Overflow用户
提问于 2013-09-18 01:16:22
回答 1查看 2.5K关注 0票数 0

我使用MVC 4和带有jquery客户端脚本的Backload文件上传器。我使用nuget获得Demo包,它下载控制器和视图作为起点。

我的问题是我的本地服务器和我的在线服务器,在我上传文件后,应用程序不能准确地显示所有上传的文件。通常情况下,它只能显示4或5个文件,而忽略了其他文件。即使我删除其中一个正在显示的文件并刷新页面,它仍然显示相同的4或5个图像。我已经验证了应用程序正在上传和/或删除这些文件。我尝试通过点击cntl F5来清除缓存,但没有结果。

谁能为我指出正确的方向来纠正这个问题。下面是从NuGet下载的演示提供的视图和控制器。

主计长:

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Spotless_Interiors.Controllers
{
    [Authorize]
    public class BackloadDemoController : Controller
    {

        public ActionResult Index()
        {

            return View();
        }


    }
}

意见:

代码语言:javascript
复制
@{
    ViewBag.Title = "File Upload";

}

@section topScripts {
    @Styles.Render("~/Content/themes/base/css")
    @Styles.Render("~/Content/css")

    <!-- We use Backloads. bundeling feature to register only those client side javascript and style files of the jQuery File Upload Plugin
         that are needed  -->
    @Styles.Render("~/bundles/fileupload/bootstrap/BasicPlusUI/css")

     <!-- Bootstrap CSS fixes for IE6 -->
    <!--[if lt IE 7]><link rel="stylesheet" href="/Content/FileUpload/css/bootstrap/bootstrap-ie6.debug.css"><![endif]-->

    <!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
    <!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
}

@section scripts {
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")

    <!-- We use Backloads. bundeling feature to register only those client side javascript and style files of the jQuery File Upload Plugin that are needed  -->
    @Scripts.Render("~/bundles/fileupload/bootstrap/BasicPlusUI/js")

    <!-- Initialize the jQuery File Upload Plugin -->
    <script src="~/Scripts/FileUpload/backload.demo.js"></script>

}


 <div>
        <!-- The file upload form used as target for the file upload widget -->
        <form id="fileupload" action="/Backload/UploadHandler" method="POST" enctype="multipart/form-data">
            <!-- Redirect browsers with JavaScript disabled to the origin page -->
            <noscript><input type="hidden" name="redirect" value="/"></noscript>
            <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
            <div class="row fileupload-buttonbar">
                <div class="span7">
                    <!-- The fileinput-button span is used to style the file input field as button -->
                    <span class="btn btn-success fileinput-button">
                        <i class="icon-plus icon-white"></i>
                        <span>Add files...</span>
                        <input type="file" name="files[]" multiple>
                    </span>
                    <button type="submit" class="btn btn-primary start">
                        <i class="icon-upload icon-white"></i>
                        <span>Start upload</span>
                    </button>
                    <button type="reset" class="btn btn-warning cancel">
                        <i class="icon-ban-circle icon-white"></i>
                        <span>Cancel upload</span>
                    </button>
                    <button type="button" class="btn btn-danger delete">
                        <i class="icon-trash icon-white"></i>
                        <span>Delete</span>
                    </button>
                    <input type="checkbox" class="toggle">
                    <!-- The loading indicator is shown during file processing -->
                    <span class="fileupload-loading"></span>
                </div>
                <!-- The global progress information -->
                <div class="span5 fileupload-progress fade">
                    <!-- The global progress bar -->
                    <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                        <div class="bar" style="width:0%;"></div>
                    </div>
                    <!-- The extended global progress information -->
                    <div class="progress-extended">&nbsp;</div>
                </div>
            </div>
            <!-- The table listing the files available for upload/download -->
            <table role="presentation" class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
        </form>  

        <!-- The template to display files available for upload -->
        <script id="template-upload" type="text/x-tmpl">
        {% for (var i=0, file; file=o.files[i]; i++) { %}
            <tr class="template-upload fade">
                <td>
                    <span class="preview"></span>
                </td>
                <td>
                    <p class="name">{%=file.name%}</p>
                    {% if (file.error) { %}
                        <div><span class="label label-important">Error</span> {%=file.error%}</div>
                    {% } %}
                </td>
                <td>
                    <p class="size">{%=o.formatFileSize(file.size)%}</p>
                    {% if (!o.files.error) { %}
                        <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
                    {% } %}
                </td>
                <td>
                    {% if (!o.files.error && !i && !o.options.autoUpload) { %}
                        <button class="btn btn-primary start">
                            <i class="icon-upload icon-white"></i>
                            <span>Start</span>
                        </button>
                    {% } %}
                    {% if (!i) { %}
                        <button class="btn btn-warning cancel">
                            <i class="icon-ban-circle icon-white"></i>
                            <span>Cancel</span>
                        </button>
                    {% } %}
                </td>
            </tr>
        {% } %}
        </script>
        <!-- The template to display files available for download -->
        <script id="template-download" type="text/x-tmpl">
        {% for (var i=0, file; file=o.files[i]; i++) { %}
            <tr class="template-download fade">
                <td>
                    <span class="preview">
                        {% if (file.thumbnail_url) { %}
                            <a href="{%=file.url%}" title="{%=file.name%}" data-gallery="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
                        {% } %}
                    </span>
                </td>
                <td>
                    <p class="name">
                        <a href="{%=file.url%}" title="{%=file.name%}" data-gallery="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a>
                    </p>
                    {% if (file.error) { %}
                        <div><span class="label label-important">Error</span> {%=file.error%}</div>
                    {% } %}
                </td>
                <td>
                    <span class="size">{%=o.formatFileSize(file.size)%}</span>
                </td>
                <td>
                    <button class="btn btn-danger delete" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}"{% if (file.delete_with_credentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
                        <i class="icon-trash icon-white"></i>
                        <span>Delete</span>
                    </button>
                    <input type="checkbox" name="delete" value="1" class="toggle">
                </td>
            </tr>
        {% } %}
        </script>      
    </div>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-18 07:51:53

由于所有文件上传/删除正确,并且清除了客户端缓存,这似乎是服务器端缓存问题。您应该使用Fiddler来检查请求和响应的chache头。

您是否在配置文件中设置了缓存选项?尝试在配置文件中设置如下内容:<cacheManager lastModified="false" etag="false" expires="0" location="None" mustRevalidate="true" />。注意,据我所知,cacheManager是一个Pro特性,它在本地工作,但在具有标准许可证的远程服务器上不能工作(我的公司有一个带有源代码的企业许可证)

但是,正如我前面所说的,我认为它与您的服务器端缓存设置更相关。所以,上传一个文件,然后删除一个文件,使用Fiddler检查所有请求/响应。即使返回304,从Backload产生的Json共振应该始终反映当前文件状态。禁用Web.config中的所有服务器端缓存设置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18862381

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档