resource sharing in asp.net mvc

心不动则不痛 提交于 2020-02-08 03:01:47

问题


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!


回答1:


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:

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

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



来源:https://stackoverflow.com/questions/4617143/resource-sharing-in-asp-net-mvc

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