在asp.net mvc的资源共享 [英] resource sharing in asp.net mvc

查看:163
本文介绍了在asp.net mvc的资源共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个解决方案2 asp.net MVC2项目。一种是正常的网站访问者使用,另一种是将要由像test.com和admin.test.com子域来分离管理员后端。这个场景就像是管理员将图像添加一个新的项目(例如产品)和test.com将使用该图像来显示产品。这两个应用程序都共享一个分贝。所以没有问题,拿到项目的详细信息是从DB到来。但对于已在admin目录(admin.test.com)上传作品图片 - 任何想法如何从一般的域名(test.com)显示得到它?
还什么是跨站点甚至CSS或js文件分离资源,如图像文件,以及如何访问它们的最好方法?

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。

p.s.I'm using shared hosting.

谢谢!

推荐答案

您可以上传到第三子域或前端领域。
您上传到一个物理文件夹。此文件夹可以是appSetting值左右。

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.

所以,你在web.config中的appSettings得到类似的设置,那些:

So, you get similar settings to those in web.config appSettings:

<add key="ProductImagesPhysicalFolder" value="x:\websites\frontend\product-images" />
<add key="ProductImagesFolderUrl" value="http://frontend.com/product-images" />

上传到物理文件夹(给你设置权限在ISS以允许该文件夹的写权限),并有像一个辅助方法GetProductImageUrl(字符串映像文件名称)来获得图片的URL给它的文件名(保存在DB)。

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).

这篇关于在asp.net mvc的资源共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆