.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Force download box

Posted By:      Posted Date: September 06, 2010    Points: 0   Category :ASP.Net
Hello there, can anyone help me with my proble. The code below run perfectly. The only thing is that after the Sub DownloadFile (FilePath as String) is run the whole webpage seem to stop. The message "Download Completed!" never show at all. When I try to click on other links, it doesn't work as well. It only work when I click the refresh button. Any ideas why? Sub Download (s As Object, e As ImageClickEventArgs) DownloadFile (MapPath(FileUrl)) lblDownload.Text = "Download completed!" End Sub Sub DownloadFile(FilePath as String) If File.Exists(FilePath) Then Dim myFileInfo as FileInfo myFileInfo = New FileInfo(FilePath) Response.Clear() Response.ContentType = "application/octet-stream" Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _ myFileInfo.Name & """") Response.WriteFile(FilePath) Response.End() End If End Sub Thaning you in advance for your help. Chan

View Complete Post

More Related Resource Links

Force File Download on a Remote File Server

Hi!I'm trying to force a large (200+ MB) file to download that's on a remote server. The problem is that I can't use the "WriteFile()" function, since I'm not using a virtual path.Then, when I try:Response.AppendHeader("content-disposition",                 "attachment; filename=" + name);Response.AppendHeader("content-disposition", "attachment; filename=" + name);I get a file that has the correct name and extension, but is 0KB. Can someone please help me?!Thanks!-Eric

Force PDF download using VB.NET


I am using Visual Studio 2010.  I have created several PDFs using Adobe Acrobat Standard 9.

I am trying to force the download of the selected PDF to the user's local machine.

I am using an asp.imagebutton to trigger the code behind that first updates the SQL database with the info about the download and then calls a Public sub: ForcePDF Download.

However when the code is run it returns a usless error that tells me there was an error.

Here is the Download code I am using:

   Public Sub ForcePDFDownload(ByVal Response As HttpResponse, ByVal FullVirtualPath As String, ByVal fileName As String)

        Response.ContentType = "application/octet-stream"
        Response.Charset = "UTF-8"
        Response.AddHeader("content-disposition", "attachment; filename=" & fileName)

    End Sub

It is important that the file be downloaded to the clients local machine rather that simply send the PDF to a browser window. I have tried substituting "application/pdf" for the ContentType with the same reasults. The filename is simply the PDF name, i.e. Book1.pdf

The FullVirtualPath is sent from the calling codebehind and is obtained using:

Download and Share Visual Studio Color Schemes

The good news is that Visual Studio allows you to completely customize the editor background and text colors to whatever you want - allowing you to tweak them to create the experience that is "just right" for your eyes and personality. You can then optionally export/import your color scheme preferences to an XML file via the Tools->Import and Export Settings menu command.

Free e-books Download

This is the link where we have get free e-books for downloading

how to know when a user finish his file download successfully ?


hi all

i am doing a page to sell files online

 the paying method is by a card or bank account and the customer is not registered to the site so i want to make sure that the customer has downloaded the file successfully after that the system completes the payment operation

so if there is any way to know do that tell me please

i use c# thanx all



where can i download from SSRS?


Hi all,

My  machine is alread installed with Sql Server 2005.  I need to install sql server 2005 reporting services as a add-on.

Where can i download this from. Can anyone post the link here..?


Thanks in advance


Ten Essential Tools: Visual Studio Add-Ins Every Developer Should Download Now


James Avery does it again with his popular list of developer tools. This time he covers the best Visual Studio add-ins available today that you can download for free.

James Avery

MSDN Magazine December 2005

.NET Tools: Ten Must-Have Tools Every Developer Should Download Now


This article introduces 10 development tools that can increase your productivity, give you a better understanding of .NET, and maybe even change the way that you develop applications. The tools covered include NUnit to write unit tests, Reflector to examine assemblies, FxCop to police your code, Regulator to build regular expressions, NDoc to create code documentation and five more.

James Avery

MSDN Magazine July 2004

Download forum free for .net



I search to download forum free for .Net plateforme,




Download db from web



I want add a download backup button to my site and when the user click the mssql database will start downloading to user computer.Can i do this ?

Force password expiration after x days


Using C# and sqlmembershipprovider forms authentication, is there a way to force user password to expire and need to be reset after x number of days?

So if a user launches the website login.aspx page, when they type their userid, it will check if the password is expired and direct them to a Resetpassword.aspx page?

File Download Problem


Hi everyone,

I am using a download handler to handle the downloading of files from my website.  I am using a slightly modified code from the Microsoft article http://support.microsoft.com/kb/812406

Everything is working fine and downloading, even with large files, but it does not show the file size for any of the files to download. Even if theyre really small.

Here is my code for the handler

public class DownloadHandler : IHttpHandler

        public void ProcessRequest(HttpContext context)
            string path = "";
                path = context.Server.UrlDecode(context.Request.QueryString["src"]).DecryptString();
            catch(Exception ex)
            System.IO.Stream iStream = null;

            byte[] buffer = new Byte[10000];

            int length;

            long dataToRead;

            string filename = System.IO.Path.GetFileName(path);

                iStream = new System.IO.FileStream(context.Server.MapPath("~/" + path), System.IO.FileMode.Open,
                            System.IO.FileAccess.Read, System.IO.FileShare.Read);


Problem download file from SQL Server


Hello everyone. I am having an issue downloading files that I have store in SQL Server. I have no problem in a WinForm. What am I doing wrong in my code?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim sch As New clsReport
        Dim fileData As New clsReport.Letter
        fileData = sch.DownloadLetter(Session("LetterID"))
        Dim ms As System.IO.MemoryStream = fileData.fil

        Dim fil As Byte() = ms.ToArray
        Dim nam As String = fileData.name
        Dim ext As String = fileData.ext
        If Not fil Is Nothing Then
                ' Response.Clear()
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + nam & "." & ext)
                ' Response.AddHeader("Content-Disposition", nam & "." & ext)
                Response.AddHeader("Content-Length", fil.Length.ToString)
                Response.ContentType = "Application/octet-stream"
                Response.Buffer = True
            Catch ex As Exception
            End Try

        End If

    End Su

The file reached the maximum download limit. Check that the full text of the document can be meaning



I'm facing an issue with the indexing.

I have 1 WFE+Index server+DB server.

Index server is not installed with MS FIlter pack 1.0

When crawling, the there will be document with warning in crawl log:
The file reached the maximum download limit. Check that the full text of the document can be meaningfully crawled.

Documents that with warning are such as doc, ppt, xls, docs, ppts and many others.
However, I view into the successful crawled document, there are doucments with ext doc and ppt.

For large file index, there are MaxGrowthFactor + MaxDownLoadSize required to be added into the index server.

As my understanding is, MS Filter Pack should installed into index server(already did, correct me if i'm wrong).

I looked into the Office SharePoint Seach(CA>Services in farm), if the server is appointed to "Use this server as indexing server", then MS Filter Pack is suppose to be installed into that particular server as well.

At the bottom, there also has another option is "Use all web front end for crawling".

The question here is, IF the option "Use all web front end for crawling" is selected.
Does the WED FRONT END Server required to installed the Ms Filte

SharePoint Developer Training Kit Download

Download presentations, videos, labs, and demos that provide advanced guidance about how to develop for SharePoint.

Download the SharePoint 2010 SDK (RTM)

All the conceptual topics and managed code reference of the SharePoint 2010 SDK are now available for you to download in one convenient package.

Download the PowerPoint Files Used in Sessions During the SharePoint Conference

View PowerPoint files that represent a selection of the ten most popular SharePoint 2010 and Office 2010 developer track sessions at the conference.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend