how to know which Image has been requested C#,ASP.Net

后端 未结 4 1759
遥遥无期
遥遥无期 2021-01-28 12:09

I am developing a web app. which will generate a random link pointing to an image on my server. something like -http://dummy.com/Images/Image1.jpg?id=19234

Here this lin

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-28 12:38

    You can change your image extension to an aspx extension (http://dummy.com/Images/Image1.aspx?id=19234), there is no problem in this, because this page the only thing it would do Response.OutputStream of the image. That is to say it would be similar to a jpg but with the advantage you can have some other code to process.

    In this aspx (before outputing the image), we would ask about the http_referer and it would be stored in a data table if this registry does not exist.

    This is really useful if for example you want to restrict the access to images. You could add some logic to forbid if they are not logged in.

提交回复
热议问题