Sending files to the browser

Sending files to the browser

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:

' 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("")    Response.Write("

Here's the document you've requested

") Response.WriteFile(path) Response.Write("")Else ' Else display an error message. Response.Write("Sorry, no document with this name.")End If

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes