Buongiorno a tutti,
ho bloccato l'accesso diretto ai file aggiungendo un event handler
come vedete blocco l'accesso diretto a tutti i file presenti nella cartella ma vorrei comunque consentirecodice:using System.IO; using System.Web; using System.Globalization; namespace MVPHacks { public class NoLeechImageHandler : IHttpHandler { public void ProcessRequest(System.Web.HttpContext ctx) { HttpRequest req = ctx.Request; string path = req.PhysicalPath; string extension = null; if (req.UrlReferrer != null && req.UrlReferrer.Host.Length > 0) { if ( CultureInfo.InvariantCulture.CompareInfo.Compare(req.Url.Host, req.UrlReferrer.Host, CompareOptions.IgnoreCase) != 0) { path = ctx.Server.MapPath("~/images/backoff.gif"); } } string contentType = null; ctx.Response.StatusDescription = "Image not found"; ctx.Response.StatusCode = 404; } public bool IsReusable { get {return true; } } } } <configuration> <system.web> <httpHandlers> <add verb="*" path="Document/*.*" type="MVPHacks.NoLeechImageHandler, MVPHacks "/> </httpHandlers> </system.web> </configuration>
la visualizzazione degli stessi passando attraverso una pagina ( che verifica il login e i ruoli)
grazie

Rispondi quotando