Originally wanted to write the summary slowly, the result today came a new project, but also busy.
Write a note about it, there is a general impression, the future also good to know where to find.
The title is not ready to write, in fact, this project needs to connect Azure virtual machine, that is Ms.
Then the virtual machine is not able to connect remotely, when you operate on Azure is clicked on the link virtual machine button, and then let you download an RDP file, open this file to enter your username password can be connected to the account.
In fact, this RDP file is a txt, inside the two lines, long like this.
Full address:s:xxxx.xxxxx:xxxx
Prompt for Credentials:i:1
The first paragraph xxx is the name of the cloud service, the second domain name, the third port.
(after the project actually did not know, Azure set up a virtual machine, first to build a cloud service, then storage space, network, and finally the virtual machine, this section of course ...) I didn't write it, I thought I'd write it down.
Too much nonsense, continue to say download this file.
1. First the background to generate the contents of this file
Virtualmachinegetremotedesktopfileresponse remotefile= ComputeManagementClient.VirtualMachines.GetRemoteDesktopFile (ServiceName, ServiceName, vmName); This direct copy must be wrong 233333, I save the instantiation. And this second parameter is the deployment name, which is the name of the deployment, and I have the same name as the service.
byte[] File = Remotefile.remotedesktopfile;
Return File (new MemoryStream (file), "Text/plain", vmname+ ". RDP");
This will return the contents of the file in the background.
2. Front desk, that is, I was the pit to the place, the main or ie protection mechanism.
var blob = new blob ([data], {type: " Text/plain "}); var fileName = vm. Vmname+ '. RDP ' ; var a = document.createelement ("A" ); Document.body.appendChild (a); A.download = FileName; A.href = Url.createobjecturl (BLOB); try {A.click (); catch (E) { Navigator.mssaveblob (BLOB, fileName); }
That data is back in the background things, at first I was only written A.clcik, and then a few days--found that IE under the use of, and then noticed that IE is forbidden to do this kind of simulation click AH and other operations.
So search some methods, try to Mssaveblob when found can, so use this, of course I just ff,chrome, and IE11, other problems again.
Finish your homework.
A tag Download file