Even I got the same problem as me, as below.
After downloading the file When redirecting to the same page or some other page in your project this problem can be avoided.
Example:
In my aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm.aspx.cs" Inherits="WebApplication.WebForm" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </div> </form> </body> </html>
Even I got the same problem as me, as below.
After downloading the file If you are redirected to the same page or to another page of your project. After the redirect, the answer will not be there as soon as you are redirected.
In my aspx
In my code
public partial class WebForm : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string path = Server.MapPath("~"); path = path + FileUpload1.FileName; FileUpload1.SaveAs(path); Response.Redirect("WebForm.aspx");
Here, to show successful messages and error messages, try using sessions.
Rajeshkdev
source share