Click here to Skip to main content
15,919,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
in my asp.net web page ,if user click button,it takes db backup from server store it on their system(from server to client system).I already wrote stored procedure for taking db backup.Now,I dont know how to save that backup file(dbbackup.bak) in client system from server??

Pls guide me friends.....
Posted

C#
string FilePath = Server.MapPath("") + "\\dbbackup.bak";
        Response.ContentType = "image/jpeg";
        Response.AppendHeader("Content-Disposition", "attachment; filename=dbbackup.bak");
        Response.TransmitFile(FilePath);
        Response.End();


Try this may help...
 
Share this answer
 
Comments
Sandip.Nascar 23-Aug-12 4:32am    
Response.ContentType = "image/jpeg";? Do you still think, it works?
Sunil Kumar Pandab 23-Aug-12 7:25am    
Try this it may help...
It works for xml/excel/word file...
I have not tried for .bak file.
Hoping it will work...
 
Share this answer
 
In one word, you cannot store any file from server to your client unless you refer the link that contains the .bak file name ( way is to just mention path of file in anchor tag's ) along with path (provided you saved it in your application path).

But still I think, this is not a good approach from security point of view. As this is a database backup and you definitely need not allow other user to access the file.

Are you using dedicate server or shared hosting?
In either case, the best way is to write a ftp access code in .Net, and save the data from server to your end. This is much secured.

Hope this helps.
cheers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900