how to open word file on browser in asp.net

protected void Button1_Click(object sender, ImageClickEventArgs e)
    {
        string FullFilePath =//path of file //"D:\\ASP\\ASP.doc";
        FileInfo file = new FileInfo(FullFilePath);
        if (file.Exists)
        {
            Response.ContentType = "application/vnd.ms-word";
            Response.AddHeader("Content-Disposition", "inline; filename=\"" + file.Name + "\"");
            Response.AddHeader("Content-Length", file.Length.ToString());
            Response.TransmitFile(file.FullName);
        }
    }

Leave a comment