How to allow ASP. NET to access network Disks

Source: Internet
Author: User

A problem to be solved in recent work is to allow ASP. NET to access the network disk, read the PDF file and open it in the browser.

 

At first, I thought it was very simple, that is, to directly map the network hard disk and then directly call directory. the getfiles function has a problem. As a result, it takes several days because the getfiles function cannot return a value because of ASP. net is not authorized to access the network disk. in this way, only impersonate can be used. However, if impersonate is used again, an error is always reported and the expected result cannot be obtained.

 

Baidu, Google, failed, and finally gathered various directors to solve the problem.

Assume that the server where the webpage is located is websvr, and the server where the network disk is located is filesvr.

1. Create a new user on filesvr that can access the network disk. Assume the user is test and the password is 1234.

2. Similarly, to create an identical user test on websvr, the password should be exactly the same, which is 1234 (Note: if there is a letter, it is obvious that the password should be the same)

3. the rest is simple, and ASP is used directly. net impersonate, in the web. add <identity impersonate = "true" username = "test" Password = "1234"/>

 

The only difference is that username & password is exposed in plain text. Of course, the user/pwd is not an important system administrator, and the result is acceptable.

However, the test results only pass the network file path in UNC format. It still does not work for ing Network hard disks. However, this result can only be accepted first.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.