c# - how to delete file in asp.net mvc using jquery -


my script

$("#btndelete").click(function () {     $.post(url, { filename: _filenameattachementphoto }, function (data) {         $("#resumepart4").html(data);     }); }); 

my controllers

[httppost] public actionresult deleteconfirmed(string filename) {     var path = path.combine(server.mappath("~/app_data/uploads"), filename);     fileinfo file = new fileinfo(path);     if (file.exists) {         file.delete();     }     return redirecttoaction("deleteconfirmed"); } 

i tried nothing happened.

try this

 $.post('@url.action("deleteconfirmed", "controllername")',             {                 filename: filename             }); 

Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -