c# - How to download file without specific content type -


i want download file. can download images.

i have this:

[httppost]         [validateantiforgerytoken]         public actionresult downloadfile(downloadfilemodel model, string filename, int fileid)         {             //var extension = path.getextension(model.filename).trimstart('.');             //var extensies = seneca.sfslib.filesystemhelper.uploadoptinextensions.contains(extension);             string customerschema = sfshelpers.statehelper.getschema();             templatelibraryentry entry = gettemplatelibraryentry(model.designid, customerschema);             filetree tree = createtree(model.designid, entry.filepath);                        fileinfo fileinfo = new fileinfo(tree.files[fileid].fullpath);             directoryinfo directoryinfo = new directoryinfo(tree.files[fileid].fullpath);              try {                 var fs = system.io.file.openread(fileinfo + model.filename );                 return file(fs, "application/jpg", filename);             }             catch {                 throw new httpexception(404, "couldn't find " + model.filename);               }                     } 

but if download file now, see every time downloadfile. mean dont see fil name , extensie

thank you

if using .net 4.5 or newer has built in support grab mime type straight filename.

msdn link

you do:

return file(fs, system.web.mimemapping.getmimemapping(filename), filename); 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -