简体   繁体   中英

ASP.net MVC window.open URL not working

My existing code is here:

function opendocpdf_click() {
        var docloc = '/App_Data/Test_Project_Documents.pdf'
        window.open(docloc);
    }

The above code doesn't working, it seems 404.8 not found error. but the below code is working fine, what can i do for above code can work.

 function opendocpdf_click() {                       
     var docloc = 'E:/palanisamy/Projects/Sample/App_Data/Test_Project_Documents.pdf'
        window.open(docloc);
    }

thanks in advance.

ASP.NET will not serve files stored in App_Data ; it is a special folder . If you want the files publicly available, you'll need to do one of the following:

  1. Store the files in a different, regular folder.
  2. Create a handler or page in ASP.NET that will take the name of a file and look for it in App_Data, and then response binary write it back to the client.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM