0
Looking on the internet I saw some websites saying that when you own a property Upload on the page can not give POST the same because it goes into looping.
I have an application that creates/deletes folders and displays an alert message (server) where a POST on the page thus making enter the looping, and thus returning error.
My question would be, how to give a POST on the page in order to update the form information without entering it looping?
Example of the Load Fileupload File event:
protected void BtnCarregar_Click(object sender, EventArgs e)
{
try
{
string caminho = ConfigurationManager.AppSettings["PastaRaiz"];
var source = Directory.GetDirectories(caminho).Select(c => new DirectoryInfo(c).Name).ToList();
if (ddlFolders.SelectedValue != null)
{
if (FileUpload1.HasFile)
{
string fileName = FileUpload1.FileName;
if (!Directory.Exists(caminho + ddlFolders.SelectedValue + "/" + fileName))
{
FileUpload1.PostedFile.SaveAs(caminho + ddlFolders.SelectedValue + "/" + fileName);
}
else
{
mensagens.ExibirMensagem("Mensagem", "Arquivo já existente no diretório.", false, this.Page, this.GetType());
}
}
}
mensagens.ExibirMensagem("Mensagem", "Arquivo carregado com sucesso.", false, this.Page, this.GetType());
}
catch (Exception ex)
{
throw ex;
}
}
Have some example code to put in your question?
– Don't Panic
@Don'tPanic added
– Igor Carreiro
What is the error shown?
– Leandro Angelo
@Leandroangelo It’s not exactly a mistake, but I give POST on this page she gets in a looping at this event. But if I do not give the POST I can not update the form, pq everything is done via Server side
– Igor Carreiro
It seems to me you’re confusing loot with delay in response. If the user is uploading a file, the request will be "suspended" until the end of this load
– Leandro Angelo
@Leandroangelo is not that. I do not save in the database, so do not need to do data conversion. It is direct to a physical directory. I added the question to the image that returns to me when I try to refresh the page.
– Igor Carreiro
This image is from when you try to refresh the page of a form that has already been posted and there was no redirect to a different destination. In your case, by the click event, I suppose it comes to webform and a postback.
– Leandro Angelo