Ciao Ciro,
se hai già implementato l'autenticazione e sei logato nel sistema ti basta aggiungere un metodo che restituisce il file ed aggiungere l'attributo System.Web.Http.Authorize. Esempèio con immagine:
ora ti basta raggiungere l'indirizzo dopo esserti logato, questo dipende da come gestisci il metodo, ad esempio in webApi potrebbe essere tipo: /api/miaApi/GetImage?id=miaImmagine, ma dipenderebbe dalla tua route.codice:[System.Web.Http.Authorize] [HttpGet] public HttpResponseMessage GetImage(string id) { string path = HttpContext.Current.Server.MapPath("~/images"); string FilePath =Path.Combine(path, string.Format("{0}.jpg", id)); if (!File.Exists(FilePath)) FilePath = Path.Combine(path, "default.jpg"); HttpResponseMessage response = new HttpResponseMessage(); response.Content = new StreamContent(new FileStream(FilePath, FileMode.Open, FileAccess.Read)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); return response; }

Rispondi quotando