ASP. NET shared folder access (including detailed operation steps) Asp.net access to the network ing Disk

Source: Internet
Author: User

Blog to find (http://zzk.cnblogs.com) index files take up too much space, need to move to another server, so to solve the problem of "access index files through shared folders in ASP. NET.

Assume that the ASP. Net program you are looking for is located on server a, and the index file is located in the zzkindex shared folder on server B. The access address is \ 192.168.18.18 \ zzkindex \. To achieve this, you can read and write files in the Shared Folder \ 192.168.18.18 \ zzkindex \ in the ASP. NET program of server.

Refer to Asp.net in the garden to access the network ing disk. We have solved this problem and will share it here.

Procedure:
(Note: server a is the server where ASP. NET programs are located, and server B is the server where shared folders are located)

  1. Create a Windows account with the same user name and password on the two servers (both server a and server B must be created). For example, assume that the user name is zzkindexer and the password is zzk.cnblogs.com.
  2. Cancel the remote control permissions of the zzkindexer account on the two servers (so that this account has as few permissions as possible), such:

  3. Remove the zzkindexer account on server B from all user groups (including users), for example:

    Does not belong to any user group? Yes. Do not doubt that it has been tested in practice.

  4. Create a shared folder zzkindex on server B and grant the write permission to the zzkindexer account. You need to set two permissions: file system permission and shared permission.
    File System permission settings are as follows:

    The share permission settings are as follows:

  5. Create a virtual directory in IIS of server A to point to the shared folder of server B, for example:

    Click "OK". If the access to the path '\ 192.168.18.18 \ zzkindex' is denied.
  6. In the Web. config file of ASP. NET program of server a, add account simulation settings:
    <system.web>
    <identity impersonate="true" userName="ZzkIndexer" password="zzk.cnblogs.com"/>
    </system.web>
  7. On server a, set "C: \ WINDOWS \ Microsoft. net \ framework64 \ v4.0.30319 \ temporary ASP.. Net files, and grant the zzkindexer Account Modification permission (Note: v4.0.30319 is the current.. NET Framework Version ). Otherwise, an error occurs during running: The current identity (zzkindexer) does not have write access to 'C: \ windows \ Microsoft. net \ framework64 \ v4.0.30319 \ temporary ASP. net files '.
  8. Everything is ready, only test is not available! Use a simple test. ASPX page to test the Code 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, check the content in the zzkindex shared file of server B:

    Done!

Summary

"Solving problems + writing a blog" may take twice as long as "solving problems + not writing a blog", but after writing it, you no longer have to worry about this problem again, there will never be such a depressing problem again: someone asked me a problem I had solved, but I forgot how it was solved.

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.