Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

How to download file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim McGavin - 29 Jun 2007 22:09 GMT
When I make a link like this on my page...

http://www.domain.com/file1.smp

I get "page not displayed".  The extension SMP is not a typical extension.
It needs to launch a local application.  Similar to the way a DOC extension
would launch word.

Do I need to use ASP to do this?  It seems to me that I should be able to
make this happen using just HTML.

Thanks!!
Nathan Sokalski - 30 Jun 2007 03:48 GMT
What local application is launched depends on the user's browser settings,
so for the most part you cannot control what application is launched. If you
want the file to be downloaded (which is what I am guessing you are asking
based on the subject), you will need to use a few methods of the Response
object. Here are some of the most important ones:

Response.ClearContent()
Response.ContentType  (I have included a function below to help determine
the value for this)
Response.AddHeader("content-disposition", "attachment;filename=" &
txtFileToDownload.Text)  (see the documentation for more details on the
parameters for this method)
Response.WriteFile()
Response.End()

Here is a function to help you determine the value for Response.ContentType:

Public Function GetMimeType(ByVal extension As String) As String
   Dim regkey As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(extension.ToLower())
   If regkey IsNot Nothing AndAlso regkey.GetValue("Content Type") IsNot
Nothing Then
       Return CStr(regkey.GetValue("Content Type"))
   Else
       Return ""
   End If
End Function

Hopefully all this will help you accomplish whatever you needed. Good Luck!
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

> When I make a link like this on my page...
>
[quoted text clipped - 8 lines]
>
> Thanks!!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.