小编msh*_*t12的帖子

MultipartFormDataStreamProvider的问题

我正在尝试按照本教程,我意识到即使我复制并过去他的代码,我的ApiController中也会遇到两个编译错误.

IEnumerable<HttpContent> bodyparts = Request.Content.ReadAsMultipartAsync(streamProvider);
Run Code Online (Sandbox Code Playgroud)

这告诉我,ReadAsMultipartAsync的返回不能强制转换为HttpContent的IEnumerable.

IDictionary<string, string> bodypartFiles = streamProvider.BodyPartFileNames;
Run Code Online (Sandbox Code Playgroud)

这告诉我在StreamProvider中不存在BodyPartFileNames,这似乎与教程以及我见过的其他一些博客帖子和StackOverflow问题相反.

任何人都知道这笔交易是什么?

完整档案:

using AsyncFileUpload.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;


namespace AsyncFileUpload.Controllers
{
    public class UploadingController : ApiController
    {
        private const string PATH = "C:\\_projects\\learning";

        [HttpPost]
        public async Task<IList<FileDesc>> Post()
        {
            List<FileDesc> result = new List<FileDesc>();
            if (Request.Content.IsMimeMultipartContent())
            {
                try
                {
                    if (!Directory.Exists(PATH))
                    {
                        Directory.CreateDirectory(PATH);
                    }

                    MultipartFormDataStreamProvider streamProvider =
                        new MultipartFormDataStreamProvider(PATH);

                    IEnumerable<HttpContent> bodyparts = …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-web-api

9
推荐指数
1
解决办法
9751
查看次数

在单击元素之前,JQuery onclick不断触发

我已经看了十多问题有关使用onclick,click,bind("click", ...),on("click", ...),等,还没有发现我有这个问题.

基本上它是一个可扩展的div,在不扩展时会隐藏一些内容.我正在使用collapse带有数据切换按钮的Twitter Bootstrap 类来扩展/折叠内容本身,但我还需要修改容器div的CSS以增加高度,以便在视觉上,内容所在的框将拉伸包含它.

这是我的脚本代码:

$(document).ready(function() {
    $("#expand-button").bind('click', expandClick($));
    document.getElementById("#expand-button").bind("click", expandClick($));
});

function expandClick($) {
    $("#outer-container").animate({ "height": "350" }, 500);
    $("#expand-button").html("^");
    $("#expand-button").bind("click", collapseClick($));
};

function collapseClick($) {
    $("#outer-container").animate({ "height": "50" }, 500);
    $("#expand-button").html("V");
    $("#expand-button").bind("click", expandClick($));
}
Run Code Online (Sandbox Code Playgroud)

这个想法很简单,处理程序根据按钮的状态旋转进出.实际发生的是,只要我加载页面,就会立即执行expandClick函数,这会导致我的容器无限循环,尽管没有被点击,但是上下都会弹跳.

有任何想法吗?

此外,我不认为它应该是相关的,但HTML看起来像:

    <div id="outer-container" class="container-fluid subsession-collapsed">
        <div class="row-fluid" style="height: 50px">
            <!-- OTHER STUFF... -->
            <div class="span1" id="4">
                <button id="expand-button" class="btn-success" data-toggle="collapse" data-target="#expandable">V</button>
            </div>
        </div>
        <br /><br />
        <div id="expandable" class="row-fluid collapse"> …
Run Code Online (Sandbox Code Playgroud)

jquery twitter-bootstrap

2
推荐指数
1
解决办法
528
查看次数

JQuery文件上载插件,Internet Explorer和IFrame传输

我正在使用这个插件(只是基本版本),并利用所有简洁的功能进行更新,以使用我自己的UI(使用Knockout.js和Twitter Bootstrap).以下是上下文的一些代码片段:

    // The file is sent to an ASP.NET MVC Web Api service to do all the business logic/DB stuff
    uploadUrl = http://web.api.url/?apikey=key

    $("#fileUpload" + "@index").fileupload({
        headers: {
            'Authorization': "@Html.AccessToken()",
            'Accept': $.support.ajax ? "application/json" : "text/plain"
        },
        url: uploadUrl,
        add: function (e, data) {
            $.each(data.files, function (index, file) {
                // add to KO viewmodel
            });
            data.submit();
        },
        fail: function (e, data) {
            var error = data.errorThrown;
            var text = data.textStatus;
        },
        done: function (e, data) {
            // …
Run Code Online (Sandbox Code Playgroud)

iframe jquery file-upload internet-explorer-9 knockout.js

2
推荐指数
1
解决办法
6526
查看次数