开发者

pass in filename into controller

开发者 https://www.devze.com 2023-03-03 21:56 出处:网络
i am try开发者_运维技巧ing to pass in a filename as a requestparameter into a controller, but it returns with an invalid request?

i am try开发者_运维技巧ing to pass in a filename as a requestparameter into a controller, but it returns with an invalid request?

 $(document).ready(function (event) {

        $('#btnTask').click(function () {

            $.ajax({
                url: "/Home/Sometask/",
                data: "c:\\somefile.txt",
                async: false,
                success: function (data) { alert(data); }
            });

            event.preventDefault;
        });

    });    


    public string Sometask(string id)
    {
        return "ready";
    }


Use data: { filename: "c:\\somefile.txt" }

You have to give a variable name for the post data so your controller know how to map the value.

0

精彩评论

暂无评论...
验证码 换一张
取 消