简体   繁体   中英

Help with file download in asp.net

 protected void imgbtn_BBDownload_Click(object sender, EventArgs e)
    {
Response.ContentType = "application/exe";
Response.AppendHeader("Content-Disposition","attachment; filename=bb.exe");
Response.TransmitFile( Server.MapPath("~/Resources/bb.exe") );
Response.End();
    }

I want to download the bb.exe file which is inside a Resource folder. I have a login form in the same screen, instead of downloading the file, the username password validation is done and the validiation summary username and password is required is shown. what is wrong with the code. Or if these is any easy method to do, pls suggest. thanks

By default all controls on page are validated, since all controls validation group is same (ie, blank). Add validation group to login / password / submit button controls. It will then validate only when u click login button but not download file click button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM