C# web application file transfer - c#

I have a web application in asp.net and C# that must access a remote server to copy some files. The web application basically deploys other web applications.
Let us say that the web app runs on a "developement" server and needs to interact with a "production" server. From the user's point of view they are both remote machines. He accesses the application (running on the "developement" machine) on his browser and does not see the code and the access credentials to the "production" machine.
At some point, it needs to copy .ascx, .aspx, .cs files from the developement to the production machine. I hope this is clear ^___^
Can anyone tell me what is the best way to do the file transfer?
Thanks!!!
Sep

If the machines are on the same network, a simple File.Copy using UNC paths (\\myserver\sharename\folder\file.ext) will do the trick.
If they are further apart, you could use FTP (FtpWebRequest on MSDN) to send files to a remote FTP server (assuming there is one) - or host an FTP server on your development machine (IIS can do that) and have the production machine download from it; regular HTTP would work in that instance too.
Finally if there are firewalls and god-knows-what-else in the way, you could write a web service/request handler on your deployment server that will serve files to the remote machine, which downloads them.
Unless you have LAN/UNC network access to the remote machine, there will almost certainly need to be a component installed on the remote machine to facilitate the copy.
To set up the application (copying files won't necessarily do it; you might need configuration too) you can use WMI, to script IIS actions - or you can use the System.Management classes to do this straight from .NET:
http://learn.iis.net/page.aspx/163/managing-applications-and-application-pools-on-iis-70-with-wmi/
Hope that helps, or at least gives some food for thought..

Related

Querying local Active Directory from Blazor client side module?

I have existing .NET code that queries Active Directory once downloaded and running the .exe on a domain connected computer.
Could my .exe now run as a DDL in the Blazor browser (client-module) against the local domain and avoiding the downloading & running the .exe?
I know the sandboxed environment prevents native file system access, but would it prevent LDAP queries running?
The standard answer is no.
Blazor-in-the-Browser is held to the same limitations as JavaScript.
It's not a technical problem but a security issue.
You can of course use Blazor-on-the-Server, as long as that server has access to your AD.
Your users (on an intranet with good connections) won't notice the difference.

Execute application on shared folder using resource of shared machine

I write small apps to help automate daily work of some colleagues and want to put on a shared folder on my machine so that others from local network can execute when my computer is on. I don't have the luxury of my own server so this is the best I can do.
One of which is a Winform app that connects to an Oracle database via an Oracle client and Oracle Data Access installed on MY machine to retrieve information. I would hope that people can execute the app (.exe file) when my machine is on, without installing anything on their machine. The app will write to an output file (.html) on the same folder and open it on THEIR browser.
My question is : What should I do to make it possible ? How can people run this .exe file using Oracle Client, Oracle DataAccess and .Net framework already installed on MY machine as if I am running it locally.
I mark all C# Assemblies (automatically added by Visual Studio) as Copy Local to True (Microsoft.CSharp.dll, System.Data.dll, System.dll, System.Data.DataSetExtensions.dll, System.Deployment.dll, System.Drawing.dll, System.Net.Http.dll, System.Windows.Forms.dll, System.Xml.dll, System.Xml.Linq.dll). Would people still need .Net framework installed ? My app is quite simple with only one external dll Oracle.DataAccess.dll. How about Oracle client and Oracle Data Access.
Many thanks.
Best solution for your situation is create a webservice and make the clients that'll consume your webservice instead of them making direct calls to your database. It removes system dependencies and easier maintenance.
Your colleagues can go to your computer via remote desktop if it is feasible. In the probable case that this is not feasible, you need to decide what the colleagues will see. If they only need to see the generated html and they only need to trigger the execution of your exe, then you will need to have a program which listens to a port and make sure that the given port is requested correctly by your colleagues via a small client app.
But honestly, the use-case you describe sounds like a website used by your colleagues. You can create a website in .NET, the exe you have would be the controller or code-behind depending on the approach you use and the HTML would be the response. Then the colleagues will just request your page with the port you are listening at.

designing Client Server Application in C#

designing Client Server Application in C#
I'm developing an application for copying and creating files between local network shares in 1 GB connection. This application will run on a local machine with that connection.
Now I have to introduce a Client-Server connection in a way that the User can perform the same steps from his Home PC. For that reason I have to setup a Server on the local machine which has 1GB connection to the network shares and access that server application from Home to perform the same actions as the User is on his local workspace.
Once again I want to clarify that the application now is running well on a local PC with 1 GB connection. I want to reach as much as possible to that via with the Client-Server. And once again, I'm not copying files from the Client to the Server or anything like that. It is only interaction between the local shares. So I want to be able to perform a copy function from local/share1/folder1 to local/share1/folder2 from the Home PC.
I'm new to Client-Server applications. And I have no idea how to set up that. Any recommendations/suggestions are welcome. My current application is developed in C# Visual Studio, so I believe that I should better use .NET Remoting or some other already supported by Visual Studio. All I could find on the internet is how to set-up a client server application for chat, I see nothing similar to my case.
Any design decisions or code will be really helpful at this moment.
There is no need to attach snippets of my code (I guess), because the application is already running locally and I don't have to change it.
Thanks in advance!

Is there any idea to copy file to another windows server without share folder

In my application,I have to copy a whole directory to the specified location in remote servers, and now we first make the location in the remote servers shared,then copy it.
Furthermore,the location in the remote servers are all mapped to web site in iis. That's to say,each location is a web site root path in remote server,and directories copied to the server will be made as `application(vitrual directory) and deployed.
However,our clients wonder if this is security since the root of the web site location is shared?
So I wonder if there is any way we can copy files without share folder?
Check out WMI # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394594(v=vs.85).aspx
You could probably create a simple Wcf Service which could be hosted by the iis on the target server and give an opportunity to upload files. I guess the security issues (authentication, ip filtering, etc.) can be considered easily enough and the permissions to write files to the server will be necessary only for the wcf service, executing locally.

FTP Login using Windows Credentials

We have a C# windows application that needs to be able to connect to a server on a network, download and save a file to a specified location.
We can not use a web service as we can not assume that our clients will have IIS on their server.
The way that I am considering doing it is to FTP onto the server and download the file. I can write the code to connect to the server and located the file but I have 2 questions.
Is there a way of using the windows credentials to FTP on to the remote server? (I understand that I cannot directly get the user's password).
Is there a better way of getting the file from a server other than ftp-ing on to it?
Thanks for the advice.
I'm assuming that a network share isn't an option (perhaps an external site etc).
Note that IIS isn't the only way of hosting a web-service. With WCF, you can use a console exe or a windows service to host the WCF service, which would allow you to run WCF on the server without any mention of IIS. See here. Then all you need is line-of-sight to the server, and some code that returns the file (or chunks of it, or a stream of it).
Depending on the size of the file (e.g. if it is less than 4MB) - you might consider leveraging a public MSMQ mechanism.

Categories

Resources