Visualizzazione dei risultati da 1 a 5 su 5

Discussione: Resize immagini

  1. #1

    Resize immagini

    DA PREMETTERE
    che su ASP.net sono proprio novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia novizia.
    (ce n'avrei messi ancora ma non mi va di annoiare... )

    Uso questo codice per il Resize delle immagini

    codice:
    <%@ Import Namespace="System.Drawing"%>
    <%@ Import Namespace="System.Drawing.Imaging"%>
    <SCRIPT RUNAT="SERVER">
    Sub Page_Load()
    
      Dim width as Integer = 0
      Dim height as Integer = 0
    
      try
        ' ricava dimensioni dalla richiesta
        if not Request.QueryString("nwidth") is Nothing Then
        width = Int32.Parse(Request.QueryString("nwidth"))
        End if
        if not Request.QueryString("nheight") is Nothing Then
        height = Int32.Parse(Request.QueryString("nheight"))
        End if
    
      catch ex as Exception
      End Try
    
      ' ridimensiona l'immagine se specificato
      Dim immagine as String = Server.MapPath(Request("img"))
      if Not System.Io.File.Exists(immagine) then
        immagine = Server.MapPath("/immagini/nondisponibile.jpg")
      end if
      
      call ImgRedim(immagine, width, height)
    
      ' fermo il resto della risposta
      Response.End()
    End Sub
    
    ' Funzione di redim
    Public Sub ImgRedim(immagine as String, width as Integer, height as Integer)
      Dim bmp as System.Drawing.Bitmap = CType(System.Drawing.Image.FromFile(immagine), System.Drawing.Bitmap)
    
      ' c'è da ridimensionare?
      if width>0 or height>0 then
        ' se è specificata solo la larghezza, calcola l'altezza
        if height = 0 Then
        height = Convert.ToInt32(width / bmp.Width * bmp.Height)
        End if
    
        ' (e viceversa)
        if width = 0 Then
        width = Convert.ToInt32(height / bmp.Height * bmp.Width)
        End if
    
        ' creo la Thumbnail con i parametri impostati
        Dim miniaturabmp as New System.Drawing.Bitmap(bmp, width, height)
    
        ' salvo sullo stream di output
        if immagine.EndsWith(".jpg") Then
        miniaturabmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
        else
        miniaturabmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif)
        end if
    
        ' pulizia
        miniaturabmp.Dispose()
      else
        ' salvo sullo stream di output
        if immagine.EndsWith(".jpg") Then
        bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
        else
        bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif)
        end if
      end if
    
      ' pulizia finale
      bmp.Dispose()
    
    End Sub
    
    </SCRIPT>
    Che chiaramente richiamo così:

    codice:
    img.aspx?img=tazza.jpg&nwidth=450

    Domanda semplice:
    Perchè in remoto funziona perfettamente ed in locale no? Cosa mi manca?
    (Lavoro su WindowsXP Pro con IIS 5.1)
    Questo è l'errore riportato:

    codice:
    Server Application Unavailable 
    The web application you are attempting to access on this web server is currently
    unavailable.
    Please hit the "Refresh" button in your web browser to retry your request. 
    
    Administrator Note: An error message detailing the cause of this specific request
    failure can be found in the application event log of the web server. Please review
    this log entry to discover what caused this error to occur.
    Questo maledetto event log of the web server dove sta che l'ho cercato ovunque???

    COM'E' ANTIPATICO STO ASP.NET!!!!
    Sto ancora imparando.... Chiedo comprensione!
    !...Send ME a message...!

  2. #2
    Nessuno prova a darmi una manina??
    Vi ho fatto una domanda troppo stupida e adesso non mi volete più bbbbene????
    Sto ancora imparando.... Chiedo comprensione!
    !...Send ME a message...!

  3. #3
    Utente di HTML.it L'avatar di 99eros9
    Registrato dal
    Jan 2003
    Messaggi
    2,637
    potrebbe dipendere dal fatto che l'account per aspnet (di solito l'utente è SERVIZIO DI RETE) non disponga delle autorizzazioni di accesso a tutte le directory e a tutti i file necessari per l'avvio del processo di lavoro e la gestione delle pagine ASP.NET.
    Tala är silver men tiga är guld!
    Pubblica il tuo curriculum
    Segnala il tuo sito
    Ancl

  4. #4
    Ciao Eros! ))Wow, che nome impegnativo!((
    Intanto grazie per la risposta.

    L'utente di cui parli si tratta quindi in pratica del "fratellone" di IUSR.... ho capito bene o dico una stupidata??
    A tal proposito stavo notanto che sotto Strumenti di amministrazione > Servizi, il processo
    ASP.NET State Service è sospeso (avviamento manuale). Così a naso direi che quello dovrebbe essere avviato, no?
    Sto ancora imparando.... Chiedo comprensione!
    !...Send ME a message...!

  5. #5
    SIIIIIIIIIIIII VAAAAAAAAAAAA!
    Ok, ho avviato il servizio ASP.net e aggiunto l'utente ASP.net nelle autorizzazioni di protezione della cartella. Ora funzia.

    Ti ringrazio tanto per l'aiuto, sicuramente ci ritroveremo presto!
    Besitos....
    Sto ancora imparando.... Chiedo comprensione!
    !...Send ME a message...!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.