How to download a file from Server folder

Posted by Venkat | Labels:

Now we are going to see how to download a file or image from the Server folder ie: showing file/open dialog box. For this we have to use Response object to show or get the file.

Sample Code:

        private void WriteFileToResponse()
        {
            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.MapPath("~/Download/" + FileName));
            //                    Response.AddHeader("Content-Length", file.Length.ToString());
            Response.ContentType = "application/octet-stream";

            //Write the file to the Response Output stream without buffering. 
            //This is new to ASP.NET 2.0. Prior to that use WriteFile. 
            Response.TransmitFile(Server.MapPath("~/Download/" + FileName));
            Response.Flush();
            Response.End();
        }

HTML Validation

Posted by Venkat | Labels: ,

As we used the Embed tag for embed the Flash files , on home or master page as this tag not support for HTML Validation (W3C) . but still we used this tag for showing flash file , if you want to do HTML validation for your site - this makes an error , so you have to avoid this.


Instead use Object tag for placing Flash files

Example:

 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" data="the-swf-file.swf" type="application/x-shockwave-flash" width="600" height="420"> <param name="movie" value="the-swf-file.swf" /> <param name="quality" value="high" /> </object>

PayOffers.in