Creating A Private Photo Gallery Using Asp.Net MVC

杀马特。学长 韩版系。学妹 提交于 2020-01-22 09:37:08

问题


I need to create a photo gallery service that is managed by users. I've done this a million times using just Asp.net but I was wondering if there are any special considerations that I need to make when using Asp.net MVC.

Basically, I will be storing the actual images on the filesystem and storing the locations in a database linking the images to a specific user. The images in a user's gallery should NOT be accessible by anyone except registered users. Meaning, I need to somehow prevent users from sharing the URL of an image from a gallery with someone who is not a user of the site.

In the past I did this using some generic handlers which authenticated that the request is allowed to access the image resource. Can I use the same pattern but using Controllers instead? I was thinking of perhaps creating a Photo Controller and just a simple Get action. Would this require that I have a View just for displaying an Image?

Am I on the right track or are there better ways of doing this? (Besides storing images in the DB)


回答1:


This link explains how to create a custom ImageResult class. I was able to do exactly what I needed following it

https://blog.maartenballiauw.be/post/2008/05/13/aspnet-mvc-custom-actionresult.html




回答2:


It's not a complete answer but I'd look at using a route that restricts access to the actual files themselves and then possibly use authentication of the action that gets an image.



来源:https://stackoverflow.com/questions/155906/creating-a-private-photo-gallery-using-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!