?
Solved

How can I build an ASP.NET site to catch files from Computer.Network.UploadFile

Posted on 2014-08-01
7
Medium Priority
?
206 Views
Last Modified: 2014-09-10
I have a Windows app that uses Computer.Network.UploadFile to FTP files to our servers.  I want to start using HTTPS rather than FTP.  According to MS here (http://msdn.microsoft.com/en-us/library/dfkdh7eb(v=vs.90).aspx) this is possible but they never explain how.  They reference 'upload.aspx' but I can't find any information on what this site needs to include.  I need this to be a protected site so the UN and PW field will be included in the Computer.Network.UploadFile call.
0
Comment
Question by:RobertBroach
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40236196
Here is an example of an .aspx that can accept uploaded files (if that is what you are looking for):

WebClient.UploadFile Method (String, String, String)
http://msdn.microsoft.com/en-us/library/vstudio/esst63h0(v=vs.100).aspx

<%@ Import Namespace="System"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Net"%>
<%@ Import NameSpace="System.Web"%>

<Script language="VB" runat=server>
    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        Dim f As String
        Dim file
        For Each f In Request.Files.AllKeys
            file = Request.Files(f)
            file.SaveAs("c:\inetpub\test\UploadedFiles\" & file.FileName)
        Next f

    End Sub

</Script>
<html>
<body>
<p> Upload complete. </p>
</body>
</html>

Open in new window

0
 

Author Comment

by:RobertBroach
ID: 40239258
Bob,

Thanks for the reply.  This looks very promising but I don't see how to use the UN and PW to upload to a password protected site (standard authentication using Active Directory) with WebClient.UploadFile.  Does this only allow uploads to public sites?

With Computer.Network.UploadFile and FTP we just include the UN and PW and it works great.  MS implies here(http://msdn.microsoft.com/en-us/library/w3kksch7(v=vs.90).aspx) that it can be done.

Todd
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40239292
Please refresh my memory on how you use FTP to pass those fields, please.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:RobertBroach
ID: 40239324
Bob,

The Computer.Network.UploadFile method (http://msdn.microsoft.com/en-us/library/dfkdh7eb(v=vs.90).aspx) has UN and PW parameters.  The MSDN page says that the address parameter can use either the FTP or HTTP protocol.  We have been using this method in our Windows app to FTP files from clients computers to our servers for almost 10 years.  We want to add the option to use HTTPS because we have some corporate environments where we have trouble with FTP (firewalls, ports, antivirus software...).  We also want to switch to HTTPS to protect our clients UNs and PWs when transmitted over the internet.

Todd
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40239355
Do you mean "user name" and "password" parameters?  If so, then you can pass encrypted arguments in the query string parameters to the web page, and check those values on the web site side with the Request.QueryString collection.

P.S. Here is some good reading about "clarity" and "brevity":  

Brevity and Clarity
http://blogvault.net/brevity-and-clarity/

Clarity and brevity go hand in hand. It’s sometimes tempting to sacrifice one for the other but that is a slippery path to walk on.  You cannot skip essential details and assume that your reader knows everything. Brevity is part of clarity; some even say that it is the soul of clarity. Aren’t both one and the same, you may ask? Not quite! You can be brief and unclear or clear and verbose! The magic mantra is to be clear and brief at the same time.

I find acronyms to be brief and unclear.
0
 

Author Comment

by:RobertBroach
ID: 40239441
Bob,

UN = 'userName'
PW = 'password'

I am trying to use the Computer.Network.UploadFile method that is used in our current application that is installed on close to 100 client's computers.  I can't change that as it is not practical for me to re-install all of those current installations.  If I can figure out how to build the 'upload.aspx' page that is referred to in the MSDN article (including the user credentials) then it is a solution that I can make work.

Todd
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 40239608
Here is an example that you can use in upload.aspx, referencing query string parameters:

 Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        Dim userName As String = Request.QueryString("userName")
        Dim password As String = DecryptPassword(Request.QueryString("password"))

        If Not ValidateLogin(userName, password) Then Return

        Dim f As String
        Dim file
        For Each f In Request.Files.AllKeys
            file = Request.Files(f)
            file.SaveAs("c:\inetpub\test\UploadedFiles\" & file.FileName)
        Next f

    End Sub

Open in new window


URL example:
My.Computer.Network.UploadFile ( "C:\My Documents\Order.txt", "http://www.cohowinery.com/upload.aspx?userName=Bob&password=ADEE3D03AE")
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question