user603007
user603007

Reputation: 11804

pass in filename into controller

i am trying 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";
    }

Upvotes: 0

Views: 66

Answers (1)

DanielB
DanielB

Reputation: 20230

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.

Upvotes: 1

Related Questions