On a Windows desktop I want to right click on a file, choose a custom menu item in the popup list, which when clicked on makes an HTTP request to call an ASP page on a Windows servers. This is all inside a corporate network.
I'm thinking I will right a VB Script to perform the http request so that I can grab the fully qualified file name and pass it as a parameter.
A long time ago I did CGI based web programming using html forms with a submit button to specify the href and the form fields were sent across with the http request as name value pairs.
How can I do a similar thing in the VB Script except call an ASP page (or method) to pass the file name to the ASP page?
In the ASP page what method would the request go to? In that method I will use the file name to do some processing.
A registry entry similar to the following will allow you to right-click on any file and click on a "Do Something" item, which will use PowerShell to submit the URL with the filename at the end as the "file" parameter.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Do Something\command]
#="powershell invoke-webrequest 'http://www.mywebsite.com/?file=%1'"
If you only want this item to be available on certain types of files, then you'll need to do a little research or tinkering to find exactly where to put it. For example, for this to work only .txt files, you would replace the "*" with "txtfile".
If you want only the filename and not the entire path, you can use .NET methods to get just the filename when you process it in the codebehind.
In ASP, use the Request.QueryString to access the filename that was passed in the URL:
Dim ClientFile as String = Request.QueryString("file")
Related
Am developing asp .Net web application.
In one of my aspx file am using file to download using generic handler. Everything works great. But when am testing i felt a strange problem. That, if am uploading a image or document with file name containing aspx character for Eg; aspxphoto as file name.
Uploading doesnt have any any problem but when i try to download it is throwing error in Generic handler file as
Object reference not set to an instance of an object.
Can anyone help me why this problem happends and how can i fix it?
You will not be able to do this. The IIS handler wants to "handle" the ASPX. You should simply not allow it, or if you have to, rename it to .aspx.uploaded or something. If you allowed, it you could open yourself to hacking.
As another option, you may be able to create a virtual that implements ("no processing") - possibly using the HTTP Handler under the virtual and just disabling script / execute permissions (under handler >> Edit Feature Permission >> Script OR under Virtual >> Edit permissions >> Special >> Turn Execute off.
I would not recommend the last, since it will add complexity when migrating between test and live AND for recovery (DR).
I want to make an ASP script that can create a new page on the webserver and tell it what content that will be in the new .asp file.
How can i do that? :)
What you want to do is not to create a new page for each request. Instead you want to pre-create an ASP page that dynamically ouputs the a file based on the input of the user.
In your example of uploading a file to display. What you probably want to do is store the uploaded file somewhere and then create another ASP page that reads in the uploaded file and displays it using Response.binarywrite or response.write. Don't create a new ASP page for each uploaded file.
So for the sake of example, you would create an ASP script called "DisplayUploadedFile.asp" the code inside it would read in the file (wherever you are storing it on the server (for example in a DB) and then write it back out. The users would hit the same page regardless of which uploaded file they wanted to see with a parameter telling the script which to display. For example DisplayUploadedFile.asp?fileID=12
CAUTION: It is extremely dangerous security-wise to let users upload content that is displayed to other users. Don't do this unless you understand at a very high level what steps are necessary to make this functionality secure. Based on your question, I think it might be prudent to get a more senior programmer to review your solution before you publish it.
I am working on a bug fixing for a old asp web page. In this page, there is one field as file for user to browse a file for update. Here is what is like in the asp page:
<input type="file" name="ufile" size="50">
In the browser, this field looks like a text field and a "Browse" button. When use click on another submit button, the input field "ufile" is used for gettting file name for uploading. The asp file has a customized clsMyQuest.asp page to get query string or object. However it looks like broken when the asp project is moved from Windows server to a Linux server.
I don't want to spend time to fix the problem of clsMyQuest.asp file. Is there any way to get the file name in asp for this field "ufile". I guess that the value of this field should be an object of file or something. This object should be retrievable from Request and then the file name may be property of the object. For example, if the user click on "Browse" button to get a file like "C:\Documents and Settings\Documents\user1\example file.pdf", how can I get the file name "example file.pdf"?
If you're using the ASPUpload server component then you can access it by File.FileName
I assume you are running ASP on Mono, since it's a Linux server. You'll need to install the ASPUpload server component. From what i've heard it's tricky to get the component working on Linux
http://www.aspupload.com/
I'm working on an ASP.NET web application for our corporate intranet users. I have a form where a user should provide a path to the file on the local network (something like "\localServer\someFolder\someFile.ext") without uploading the actual file. The issue is that users don't want to type the whole file path and want to use some kind of visual browse dialog.
The standard HTML <input type=file> element allows to browse for a file, but most of the browsers (except for IE) don't allow to access file's full path, so I think it should be done by some external component like Silverlight, Flash, Java applet etc.
I tried to do it with Silverlight, but I'm getting a SecurityException when trying to access file's full path using Silverlight's OpenFileDialog class.
This java applet http://jumploader.com/demo_images.html seems to do something similar to what I'm looking for, but it's focused on uploading files - I only need to be able to get file's full path and pass it to the server as a string.
Any suggestions would be appreciated.
Telerik ASP.NET AJAX RadFileExplorer has the functionality you're looking for:
http://www.telerik.com/products/aspnet-ajax/fileexplorer.aspx
You can use their Custom File Content Provider to hook the GUI to your server's file system.
http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/server-sideapi/dbfilebrowsercontentprovider/defaultcs.aspx
This should be possible with Flash's uploading capabilities. SWFUpload has an API that you may be able to access from JavaScript to extract the selected file name without actually uploading anything. See docs here, for example getFile():
getFile is used to retrieve a File Object from the queue. The file retrieved by passing in a file id (the id property from a file object) or a file index (the index property from a file object).
I am working on a simple portal application using the ASP.NET membership and login controls. I would like to use the PasswordRecovery control to send emails containing forgotten passwords, however my portal requires localization. I have an existing Content Management System that I am pulling the localized strings out of and I would like to link the PasswordRecovery control to that system.
But, it appears that the PasswordRecovery control will ONLY accept a .txt file for the email body...the property is PasswordRecovery1.MailDefinition.BodyFileName
I do not want to use a file on disk, I would like to use the localized content in my CMS.
Is there any way to do this? It occurred to me that I might be able to use the SendingMail event to send my OWN email through the normal System.Net namespace, but that seems sorta cludgy...
Any thoughts?
Thanks,
Max
Try handling the SendingMail event of the PasswordRecovery control. In that event, set the e.Message.Body and e.Message.Subject properties to your localized text.
Found this by googling "BodyFileName localization":
http://forums.asp.net/t/1118242.aspx:
Just bind the property to a key in
your page's localresource file. The
page's local resource file is the file
located in a subdirectory called
app_localresources in your page's
directory. Just use visual studio's
"tools -> create local resource"
option in design view for it be
created for you.
In that file, create a string
key/value pair with something like
Name: myBodyFileName
Value: myDefaultBodyFile.txt
Then bind this to the BodyFileName
property of the login control with
something like
'>
Then just create the sattelite local
resource files for other cultures and
map that key/value pair in those
resources to other body text files.
By the way, if you used visual studio
to create the resource file for you,
then the binding may have been done
for you automatticaly. Just search for
a
"MyChangePasswordControlResource1.BodyFileName"
key in the resource file or something
similar.
Regards, Jorge