Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Sending files to the browser

Total Hit ( 2749)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


The ASP.NET Response object has been greatly expanded in its capability to send output to the client browser. For example, the WriteFile method can send the contents of any text, HTML, or XML file to the browser; in classic ASP you have to load the file in memory and then pass its contents to a Write method to reach the same effect. For example, you can use this method to apply a common frame and style, typically a menu bar or footer, to any .txt file:

Click here to copy the following block
' Get the name of the requested document (passed on the query string).
Dim path As String = Request.QueryString("doctitle") & ".txt"
' Convert to a physical path.
path = Request.MapPath(path)
If System.IO.File.Exists(path) Then
  ' If the file exists, send it to the browser as HTML.
  Response.Write("<HTML><BODY>")
  Response.Write("<H1>Here's the document you've requested</H1>")
  Response.WriteFile(path)
  Response.Write("</BODY></HTML>")
Else
  ' Else display an error message.
  Response.Write("Sorry, no document with this name.")
End If



Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.