asp.net - C# Download File from a network drive -


i have file located @ network drive. user access created have full access path. seems when ran following code file, browser not respond.

fileinfo file = new fileinfo(getdocumentuploadfolder(id) + filename);  // checking if file exists if (file.exists) {     // clear content of response     this.page.response.clearcontent();      // clear header of response     this.page.response.clearheaders();      // set contenttype     this.page.response.contenttype = "application/pdf";      // write file response (transmitfile asp.net 2.0. in asp.net 1.1 have use writefile instead)     this.page.response.writefile(file.fullname);      // end response     this.page.response.end(); } 

i tried using this.page.response.transmitfile(file.fullname); , not work. page seems stop functioning after this.page.response.end();

any ideas?

no matter file stored. action must return file result:

public fileresult getbytes() {    string path = server.mappath("~/files/pdficon.pdf");    byte[] mas = system.io.file.readallbytes(path);    string file_type = "application/pdf";    string file_name = "pdficon.pdf";    return file(mas, file_type, file_name); } 

server.mappath(filepath string) - must have access file.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -