Asp. NET access to shared folders Detailed steps _ Practical tips

Source: Internet
Author: User

Suppose look for the ASP.net program in a server, index file in the B server Zzkindex shared folder, Access address is \\192.168.18.18\ZzkIndex\. To achieve this is to be able to read and write files in the shared folder \\192.168.18.18\ZzkIndex\ in the ASP.net program of server A.

Specific steps to operate:

(Note: A server is the server for the ASP.net program, b server is the server for the shared folder)

① a Windows account with the same user name and same password on both servers (A and B servers are built), such as assuming that the username is zzkindexer and the password is zzk.cnblogs.com.

② Remove the remote control permissions on the Zzkindexer account on both servers (let the account have as few permissions as possible), as shown in the following figure:

③ Remove the Zzkindexer account on the B server from all user groups (including users), as shown in the following figure:

Does not belong to any user group? Yes, do not doubt, has been tested by practice.

④ Create a shared folder on the B server Zzkindex and grant write permissions to the Zzkindexer account, with two permissions to set, one for file system permissions and one for shared permissions.

File system permissions are set to the following figure:

Share permissions are set as follows:

⑤ Create a virtual directory in IIS in Server A to point to the shared folder of Server B, as shown in the following figure:

Click OK, and if there is an access denial (access to the path ' \\192.168.18.18\ZzkIndex ' denied) error, don't worry about it.

⑥ Add an account emulation setting in the Web.config file of the ASP.net program for Server A (a):

<system.web>
  <identity impersonate= "true" Username= "Zzkindexer" password= "zzk.cnblogs.com"/>
</system.web>

⑦ on the a server, set the file system permissions for "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary asp.net files", Grant Zzkindexer Account Modify permissions (Note: v4.0.30319 is the current. NET Framework version number). Otherwise, the runtime will receive an error: the current identity (Zzkindexer) does not have write access to ' C:\Windows\Microsoft.NET\Framework64\ v4.0.30319\temporary asp.net Files '.

⑧ everything, only the test! With a simple test.aspx page test, the code is as follows:

<%@ Page language= "C #" autoeventwireup= "true"%>
<script runat= "Server" >
protected void Page_Load (object sender, EventArgs e)
{
  System.IO.File.Create (Server.MapPath ("/zzkindex/cnblogs.txt"));
}
</script>

After accessing test.aspx, look at the contents of the B server's zzkindex shared file:

Summary

"Solve Problem + Write blog" Time may be "solve problem + do not write blog" twice times, but write out, you no longer have to worry about the problem again, will not appear so depressed. The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.