ASP.NET MVC中的资源共享
我的解决方案中有 2 个 asp.net mvc2 项目。一个是供访问者使用的普通站点,另一个是管理后端,它将由 test.com 和 admin.test.com 等子域分隔。该场景就像管理员将添加带有图像的新项目(例如产品),而 test.com 将使用该图像来显示产品。两个应用程序共享一个数据库。因此,获取来自数据库的项目详细信息是没有问题的。但是对于已上传到管理目录(admin.test.com)中的项目图像 - 知道如何从通用域(test.com)获取它来显示吗? 另外,跨站点分离图像文件甚至 css 或 js 文件等资源的最佳方法是什么?以及如何访问它们?
ps我正在使用共享主机。
谢谢!
I have 2 asp.net mvc2 projects in a solution. One is normal site for visitors use and the other one is admin back-end which is going to be separated by sub-domains like test.com and admin.test.com. The scenario is like admin will add a new item(e.g product) with image and test.com will use that image to display product. Both application are sharing one db. so there is no problem to get the item details that is coming from the db. but for item image that has been uploaded in admin directory(admin.test.com) - any idea how to get it from general domain(test.com) to display??
Also what is the best way of separating the resources like image files or even css or js files across sites and how to access them?
p.s.I'm using shared hosting.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以上传到第三个子域或前端域。
您上传到物理文件夹。该文件夹可以是 appSetting 值等。
因此,您将获得与 web.config appSettings 中的设置类似的设置:
上传到物理文件夹(假设您在 ISS 中设置权限以允许对该文件夹进行写入访问),并拥有一个辅助方法,例如
GetProductImageUrl(string imageFilename)< /code> 获取给定文件名的图像的 URL(保存在数据库中)。
You can upload to a third sub-domain or to the front end domain.
You upload to a physical folder. This folder can be an appSetting value or so.
So, you get similar settings to those in web.config appSettings:
Upload to the physical folder (given you setup permission in ISS to allow write access to that folder), and have a helper method like
GetProductImageUrl(string imageFilename)
to get the URL of the image given its filename (saved in DB).