mardi 28 février 2023

Need .ASPX page that will return a random .png file

I have looked all over and all the solution I found were overly complicated (way above my head). I am hoping someone can help me. I would like to create an .ASPX/.ASP file that I can use as the image src= in a web page. Upon load, the "display_random_image.aspx" page would display a random image. The use case is for a random email footer image (think random email footer image)

website structure C:<random_email_footer_images> image_1.png image_2.png image_3.png image_4.png image_5.png

c:\display_random_image.aspx source would be something like this

<html>
  <body>
    <img src="generate_random_image.aspx" />
  </body>
</html>

c:\generate_random_image.aspx would randomly select a number (1-5) and return it. Very roughly I imagine with would be something like this:

<%@ Page Language="C#" %>
<script runat="server" language="c#">

1) select a number between 1 and 5
2) load that random image into an output stream
3) return the image

</script>

I googled lots of different versions and iterations of "Response.ContentType = "image/jpeg";" random image generator etc.




Aucun commentaire:

Enregistrer un commentaire