Il tuo programma dovrebbe essere + o meno così :
Naturalmente questo è un'esempio.codice:Function GetUrl(Url) Dim Http Set Http = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0") Http.open "GET",Url,False Http.Send() GetUrl = Http.ResponseText Set Http=Nothing End Function Function WriteFile(byRef Fso,Path,Content) Dim File Set File = Fso.OpenTextFile(Path,2,true) File.Write Content File.Close() Set File = Nothing End Function Function GetHtml(Folder,Content) Dim Fso,FileName,Path,ServerName,ServerPath,PathURL 'Testo se la variabile folder ha il carattere \ finale if Folder<>"" then if Mid(Folder,Len(Folder),1)<>"\" then Folder = Folder & "\" 'Initializzo Variabili ServerName = "http://" & Request.ServerVariables("SERVER_NAME") & "/" ServerPath = Request.ServerVariables("APPL_PHYSICAL_PATH") 'Creazione Fso Set Fso = Server.CreateObject("Scripting.FileSystemObject") 'Persorso Temporaneo del file Path = Server.MapPath(Folder & Fso.getTempName & ".asp") 'Scrittura del file WriteFile Fso,Path,Content 'Trasformo il percorso fisico in url PathURL = Replace(Path,ServerPath,ServerName) 'Chiamo getUrl che mi restituisce l'html GetHTML = GetUrl(PathURL) 'Cancello il file Fso.DeleteFile Path,True Set Fso = Nothing End Function Response.Write ( GetHTML(".","<" & "%Response.Write(""Ciao"") %" & ">") )
Tu richiamera la funzione GetHTML passandogli la directory dove salvare il file e il valore del recordset
Il file verrà salvato nella percorso relativo include\ e verrà eseguito Rs("ContenutoASP")codice:GetHTML("include\",Rs("ContenutoASP"))
La funzione ti restituisce l'html della pagina.
Passandogli un nome file di destinazione, puoi salvare direttamente il file dalla funzione GetHTML senza fartelo restituire
Il tutto renderebbe meglio se fosse messo in una classecodice:Sub AspToHtml(Folder,Content,DestFile) Dim Fso,FileName,Path,ServerName,ServerPath,PathURL,HTML if Folder<>"" then if Mid(Folder,Len(Folder),1)<>"\" then Folder = Folder & "\" ServerName = "http://" & Request.ServerVariables("SERVER_NAME") & "/" ServerPath = Request.ServerVariables("APPL_PHYSICAL_PATH") Set Fso = Server.CreateObject("Scripting.FileSystemObject") Path = Server.MapPath(Folder & Fso.getTempName & ".asp") WriteFile Fso,Path,Content PathURL = Replace(Path,ServerPath,ServerName) HTML = GetUrl(PathURL) Fso.DeleteFile Path,True Path = Server.MapPath(DestFile) WriteFile Fso,Path,HTML Set Fso = Nothing End Sub

Rispondi quotando