Environment description
Two server servers are a, server is B, Server B is file server
Implementation methods
1. Create user docshareuser on A and B, keep the username and password consistent
2, b server Set up the Attachment folder attachments share, add user Docshareuser and set read and write permissions
3, in a Run the box input "\\IP\Attachments", enter the username password test whether sharing success, sharing unsuccessful please check the network and configuration problems
4, modify the Aweb.config file attachment path node value
<add key= "key value" value= "\\IP address \attachments"/>
|
5, under the <system.web> node to add the following configuration, user name password and create a shared account to maintain the same
<identity impersonate= "true" Username= "Docshareuser" password= "password"/>
|
Test Upload success! Download times wrong:
Because the download method is as follows:
Context. Response.appendheader ("Content-length", filesize.tostring ());
Context. Response.CacheControl = HttpCacheability.Public.ToString ();
Context. Response.Cache.AppendCacheExtension ("max-age=" + 365 * 24 * 60 * 60);
Context. Response.Cache.SetExpires (DateTime.Now.AddYears (1));
Context. Response.appendheader ("ETag", "never_modify");
Context. Response.Cache.SetETag ("never_modify");
Context. Response.Cache.SetLastModified (DateTime.Now.AddMinutes (-1));
Context. Response.TransmitFile (FilePath);
|
Modify the Download mode:
FileStream FS =newfilestream (FilePath, FileMode.Open);
byte[] bytes =newbyte[(int) fs. Length];
fs. Read (bytes, 0, bytes. Length);
fs. Close ();
response.contenttype = "Application/octet-stream";
//notifies the browser to download the file instead of opening the
respons E.addheader ("Content-disposition", "attachment filename=" + httputility.urlencode (filename, SYSTEM.TEXT.ENCODING.UTF8));
context. Response.BinaryWrite (bytes);
context. Response.Flush ();
context. Response.End ();
|