Download

lunedì 13 settembre 2010 - 15.53
Tag Elenco Tags  VB.NET  |  .NET 3.5

memmo77 Profilo | Expert

Salve a tutti cercavo di far aprire al click di un bottone la finestra per il download di un file e ho provato questo:

Response.ContentType = ".xls"
Response.AppendHeader("content-disposition", "attachment; filename=nome.xls")
Response.WriteFile(Server.MapPath(Session("vpath_xls") & "nome.xls"))
Response.End()

L'errore che mi restituisce è:
{Valutazione della proprietà non riuscita.}

alx_81 Profilo | Guru

>Salve a tutti cercavo di far aprire al click di un bottone la
>finestra per il download di un file e ho provato questo:
Ciao

>Response.ContentType = ".xls"
>Response.AppendHeader("content-disposition", "attachment; filename=nome.xls")
>Response.WriteFile(Server.MapPath(Session("vpath_xls") & "nome.xls"))
>Response.End()
prova ad utilizzare nel ContentType "application/vnd.ms-excel"
--
Alessandro Alpi | SQL Server MVP
MCP|MCITP|MCTS|MCT

http://www.alessandroalpi.net
http://blogs.dotnethell.it/suxstellino
http://mvp.support.microsoft.com/profile/Alessandro.Alpi

memmo77 Profilo | Expert

Nulla da fare ho modificato:

Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader("content-disposition", "attachment; filename=file.xls")
Response.WriteFile(Server.MapPath(Session("vpath_xls") & "file.xls"))
Response.End()

Potrebbe dipendere dal fatto che nella pagina ho uno scriptmanager per gestire ajax?
Grazie

memmo77 Profilo | Expert

Ho risolto così:

ScriptManager.RegisterStartupScript(Me, Me.GetType, "download", "document.location.href = qs['vpath_xls'] + 'file.xls';", True)
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5