简体   繁体   English

ASP.net MVC window.open URL不起作用

[英]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. 上面的代码不起作用,似乎找不到404.8错误。 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 ; ASP.NET将不提供存储在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. 在ASP.NET中创建一个处理程序或页面,该处理程序或页面将使用文件名并在App_Data中查找它,然后响应二进制文件将其写回到客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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