How does Asp.net upload files to another server?

Source: Internet
Author: User
How does Asp.net upload files to another server?

I use the ing Network Disk format,ProgramThe file cannot be saved to the network ing disk.
To share a folder, you must have the write permission for the folder. In this case, all people in the LAN can upload the folder to this shared directory?

Suggestion:

I just did this, huh, for your reference.
Assume that server a is a Web server, and files must be uploaded to server B through the web program on server.
1. Share a folder on B. Remember to set the permission to give a user the write permission.
2. Create a virtual directory under the website on server a. Change the point of the virtual directory to share it with another computer. Enter the user account and password you just set.
3. When uploading data on server a, obtain the upload address using the server. mappath ("virtual directory") Name.
4. To solve the permission problem, you can upload files to server B only after building trust. We recommend that you use global. load in asax, so that the website is built with confidence every time it is run. Statement for building trust:
System. diagnostics. process. start ("net.exe", "Use \ B server IP \ Shared Folder \" B server password \ "/User: \ "User Name on server B \"");
The user on server B mentioned above refers to the user who can write the shared folder!

Remember that you must be able to run the net.exe file!

test whether the virtual directory settings are correct!
assume that A is the server of your web site B is the server on which you want to upload files
1. Share a folder upload on server B, set the permission to open the user Test password 123456 and grant the test write permission to upload. At the same time, put a simple page in the folder. Everything works, output a few letters to [operation over on server B]
2. Create a virtual directory under the web site of server, when a virtual directory is added by default, you do not have to select the shared folder of other servers. You can select a local path and click the properties of the virtual directory, there are three options for changing the local path. You can select "share on another computer" and set the network path in the following format: \ {server} \ {sharing name}, {server} is replaced by an IP address, and {sharing name} is the upload folder. Fill in the file and click "Connect user" next to it ", enter the user test and password 123456 on server B just now (of course, to be simple, you 'd better test it first to make sure server a can Access the shared folder on server B. If a cannot access the shared folder on server B, solve the problem first. The test method is simple, enter \ B server IP \ upload in the browser. If you can enter the user and password, you can see the file you just created. OK, sharing is accessible)
3. After the virtual directory is set up, you can test it and obtain the path of the virtual directory through a program under website a. If the path is successful, the path should be the IP address + upload folder of server B.
4. The next step is to upload files. You can directly upload files. You have just entered the account and password used to access upload on server B, that is to say, A and B have established a trusted connection. However, if you restart the server, the connection just created does not exist. So in the global. load a sentence in the asax file so that server a establishes a trusted connection with server B at startup.
system. diagnostics. process. start ("net.exe", "Use \ B server IP \ upload \" 123456 \ "/User: \" test \"");
the preceding statement establishes a Trust connection and is stored in global. the advantage of asax is that a connection is established when the site is started, because this Trust connection is sustainable and will not expire like a session. This trust connection will disappear only when server a is restarted.

do you know? However, I am sure this can be achieved, because I have just done this.
after that, it is easier to access files uploaded to server B.
One method is to access server B through a virtual directory under server a's Web site. In this case, server B only provides space.
another method: create a site on server B to point to this directory, so that server B shares the task of IIS when accessing files.

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.