Thursday, June 10, 2010

Download a file with Save as dialog in ASP.NET

For the file in your web server folder. you can use below code to download with save as dialog in ASP.NET



Response.Clear();
Response.ContentType = "image/jpeg";
Response.AppendHeader("Content-Disposition","attachment; filename=photo.jpg");
Response.TransmitFile( Server.MapPath("~/images/photo.jpg") );
Response.End();

If you want to download a file with save as dialog from dynamically generated data, see below example


Response.Clear();
Response.ContentType = "application/ms-excel";
Response.AddHeader("content-disposition", "attachment; filename=filterlist.csv");
string outputtext="dynamic data";
Response.Write(outputtext);
Response.End();

Things to take care for web application development

Before we start web application development, We must need to take care about below points
  • Concurrency Control
  • SQL Injection
  • Cross site scripts
  • Always encrypt connections strings and passwords
  • Input validation at both side (Client and server)

Wednesday, June 9, 2010

First blog, Going to start posting my work and experience

Hello All,

This is my first blog post. Going to start posting of my work and experience as a Software engineer.