Salve, ho uno script per thumbnails automatiche, estensione aspx. Gli output per 10 immagini sono visualizzati in una pagina html.
Il problema è che, mentre su un altro dominio funzionava tutto, su quello in cui sto provando ora, appena carico la pagina, mi appare la maschera 'Richiesta' con scritto 'Inserire nome utente e password per www.dominio.com'.
Mi appare per 10 volte perchè richiamo il file aspx 10 volte.
Perchè si comporta così? Come posso evitare? Grazie.
Ecco il codice:
codice:<%@ Page Language="C#" Debug="true" %> <%@ import Namespace="System"%> <%@ import Namespace="System.IO"%> <%@ import Namespace="System.Drawing" %> <%@ import Namespace="System.Drawing.Imaging" %> <%@ import Namespace="System.Text.RegularExpressions" %> <script Language="C#" runat="server"> void Page_Load(Object sender, EventArgs e) { int ThumbnailWidth = 64; int ThumbnailHeight = 64; string strFileName = ""; string destinazione = "./"; double orgImgWidth = 0.0; double orgImgHeight = 0.0; double rThumbnailWidth = 0.0; double rThumbnailHeight = 0.0; System.Drawing.Image orgImage; if (Request.QueryString["w"] != "") ThumbnailWidth = Convert.ToInt32(Request.QueryString["w"]); if (Request.QueryString["h"] != "") ThumbnailHeight = Convert.ToInt32(Request.QueryString["h"]); if (Request.QueryString["src"] != "") { strFileName = Convert.ToString(Request.QueryString["src"]); if (Request.QueryString["percorso"] != "") destinazione = Convert.ToString(Server.MapPath(Request.QueryString["percorso"])); else destinazione = Convert.ToString(Server.MapPath(destinazione)); if (strFileName != "") { try { orgImage = System.Drawing.Image.FromFile(Server.MapPath(strFileName)); using(Bitmap tmpImage = new Bitmap(orgImage)) { rThumbnailWidth = ThumbnailWidth; rThumbnailHeight = ThumbnailHeight; orgImgWidth = tmpImage.Width; orgImgHeight = tmpImage.Height; // Se l'immagine è più piccola del Thumbnail forziamo le dimensioni di // quest'ultimo alle dimensioni dell'immagine. if (orgImgWidth < ThumbnailWidth) ThumbnailWidth = tmpImage.Width; if (orgImgHeight < ThumbnailHeight) ThumbnailHeight = tmpImage.Height; // Se le dimensioni dell'immagine e del Thumbnail corrispondono non facciamo nulla. if (tmpImage.Width != tmpImage.Height) { // Altrimenti continuiamo a fare i nostri controlli per calcolarne le // giuste dimensioni e quindi creare la nostra nuova immagine con // l'aspectratio corretto. if (tmpImage.Width > tmpImage.Height) { // L > H => tH = (H * tL)/ L rThumbnailWidth = ThumbnailWidth; rThumbnailHeight = (double)((tmpImage.Height * ThumbnailWidth) / tmpImage.Width); } // if (tmpImage.Width > tmpImage.Height) else { if (tmpImage.Width < tmpImage.Height) { // L < H => tL = (L * tH)/ H rThumbnailHeight = ThumbnailWidth; rThumbnailWidth = (double)((tmpImage.Width * ThumbnailHeight) / tmpImage.Height); } // if (tmpImage.Width < tmpImage.Height) } // else } // if (tmpImage.Width != tmpImage.Height) } // using(Bitmap tmpImage = new Bitmap(orgImage)) using(Bitmap bitmap = new Bitmap(orgImage, (int)(rThumbnailWidth), (int)(rThumbnailHeight))) { Response.ContentType = orgImage.RawFormat.ToString(); Response.Clear(); Response.BufferOutput = true; Response.AddHeader("Content-Disposition", "filename=" + strFileName); // In questo caso viene creata e salvata la Thumbnail dell'immagine in /thumbs/ if ((orgImage.Width > ThumbnailWidth) || (orgImage.Height > ThumbnailHeight)) { bitmap.Save(Response.OutputStream, orgImage.RawFormat); bitmap.Save(destinazione + "/public/gall_hotel" + strFileName, orgImage.RawFormat); } // if ((orgImage.Width > ThumbnailWidth) || (orgImage.Height > ThumbnailHeight)) else // L'immagine rientra già nella dimensione da noi decisa quindi non serve creargli il Thumbnail. { bitmap.Save(Response.OutputStream, orgImage.RawFormat); } // else Response.Flush(); } // using(Bitmap bitmap = new Bitmap(orgImage, (int)(rThumbnailWidth), (int)(rThumbnailHeight))) } // try catch (Exception ex) { Response.Write(ex.Message); } // catch (Exception ex) finally { Response.Write("\nRe-Coded by R.B. Riddick"); } } // if (strFileName != "") } // if (Request.QueryString["src"] != "") } </script>

 
			
			 
					
					
					
						 Rispondi quotando
  Rispondi quotando