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)
- 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.
- Cancel the remote control permissions of the zzkindexer account on the two servers (so that this account has as few permissions as possible), such:
- 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.
- 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:
- 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.
- 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>
- 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 '.
- 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.