Incluso tengo el mismo problema que he resuelto a continuación.
Después de cargar un archivo Si lo redirige a same page
o some other page in your project
, se evitará este problema.
Por ejemplo:
En Mi 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>
Incluso tengo el mismo problema que he resuelto, como a continuación.
Después de cargar el archivo si lo redirige a la misma página o a alguna otra página de su proyecto. Después de la respuesta de redirección no estará allí una vez que lo redirigió.
En Mi ASPX
En Mi C Detrás oda
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"); // Responce will be cleared. This Redirection will do the Trick
//Put the debugger and check it will work
}
}
Aquí, para mostrar el éxito y mensajes de error tratar de usar sesiones.
Hace un tiempo pregunté algo similar ... http://stackoverflow.com/questions/305684/how-can-i-prevent-database-being-written-to-again-when-the-browser -does-a-reload – Marty