Same virtual (global) directory for multiple websites - asp.net

I am working on multiple websites in asp.net mvc. Some websites are top level domains and some are subdomain but all these websites are hosted on same server.
www.foo.com
subfoo.foo.com
www.abc.com
a.abc.com
I want all these websites should access same directory for save and retrieve some files in this way i can manage files efficiently.
www.foo.com/assets
subfoo.foo.com/assets
Currently every website is handling data its own wwwroot directory so when i need these files on different website then i have to do lot of work for retrieval.
For this purpose i have created folder out side the websites directory and point out as virtual directory in one websites. I tried to repeat same process for other websites but can 't do this because hosting server does not permit me to point out virtual directory on same folder.
So my question is this limitation of IIS. Is there any other technique to do this task in better way?

Virtual directory is the only way I know of to do what you ask. It sounds odd that you have a limitation of one virtual directory pointing to the same folder, maybe you need a new host.

EDIT: Just realized how old this question was. Well maybe this will still be of help to someone.....
We run IIS with Approx 5 different web sites. These websites each have their own root directory. We don't typically access things from the other websites, but if we were to do this I would think we would setup another directory on the server for those files to live in. This is assuming that the files you are trying to access are static files.
To Clarify...
C:\inetpub\WebSite1Root
C:\inetpub\WebSite2Root
C:\inetpub\WebSite3Root
Then place the static files in
C:\StaticFiles
So to access those static files Website1 (or 2 or 3) would simply look in that shared directory.
I'm not sure if this helps but I would be happy to answer questions if you have any.

Related

How to setup error page handling for subdomains?

On my hosting server I want to achieve the following arhitecture of main site and subdomains:
www.site.com
subdomain1.site.com
subdomain2.site.com
All three domain have some common resources: scripts, css files, images and custom error files to present errors like 404, 503 in a creative intriguing and most entertaining way.
I have organized folders on my hosting server into this structure
www-main
www-subdomain1
www-subdomain2
shared-css
shared-errors
I have setup each subdomain as an asp.net applicatin which resides in its physical folder.
To access common shared resources I have created virtual folders for each subdomain that point to the sam physical folders.
virtual folder shared-css in subdomain1 points to shared-css physical folder
virtual folder shared-css in subdomain2 points to shared-css physical folder
This works ok. But not for folder containing error files. I have configured my web.config and files according to http://benfoster.io/blog/aspnet-mvc-custom-error-pages
The problem is that it does not work for subdomains. If I configure virtual folder as asp.net application it complains it cannot load assemblies for the application for which this folder was created. On the other hand if I configure it as ASp folder it simply does not work.
This same concept works if site is not divided into subdomains but into subfolders instead of subdomains.
Does anybody has a working solution for this problem?
Not suggestions, I have tried many things, anything I could think of.

Can not overwrite file in virtual directory

I'm having problems with a site using a virtual directory to share images between three load balanced web servers.
The three web servers all have an asp.net website installed using IIS 7.5 and a virtual directory pointing to the same shared folder. There is no problem reading the images.
The problem is that the windows service that is downloading images and writing to the shared folder gets the exception, "The process cannot access the file 'D:\WebShare\images\440.jpg' because it is being used by another process".
Is there any way to "force" an overwrite? Or should I rethink my solution? It must be a very common scenario that multiple web servers share a folder and some other process updates the files in that folder but I can't find a solution to my problem.
So I've solved the problem. I have another service running on each server copying the images to a local folder instead of each server reading the images from the same shared folder.
My guess is that the problem has something to do with the fact that an IIS website was reading from a shared folder on another server. The only difference now is that the website is reading from a local folder. I still have a windows service overwriting images in that folder.

Serving ASPX pages from outside the web root

Currently working on an internationalization project. One of the requirements is to take static files published from a content management system and serve the correct language version based on the locale. Unfortunately the published files are .aspx and include references to master pages and potentially other controls.
If the pages are inside the web root, this is pretty easy. I just have something in global Application_BeginRequest that takes a request for /abc.aspx and rewrites it to /content/[locale]/abc.aspx.
For ease of deployment and a couple of other reasons, I would really like these files to be outside the web root. e.g. site is in "D:\www_root\site\" and content is in "D:\content".
Is there a way to achieve this?
You can create a virtual directory in IIS that points to d:\content.
A virtual directory is a directory name (also referred to as path) that you specify in IIS and map to a physical directory on a local or remote server. The directory name then becomes part of the application's URL, and users can request the URL from a browser to access content in the physical directory, such as a Web page or a list of additional directories and files.

Share files (eg. swf) across multiple sites using web.config

I'm managing a flash/flex system which is shared across multiple sites on the same server.
Rather than having to store the duplicates of the same swf files on each site I would like to setup a folder on the server (windows 2008 iis7) containing these swfs and allow each site to use the same swf files. I would like to include these files somehow so the user thinks the swf files are coming from the source domain not the a shared domain.
I'm used to using coldfusion mapping to share files but this isn't available for non-coldfusion files i.e. swf
I wondered would it be possible to rewrite urls in my web.config file to these swf files?
Please could someone suggest a way to do this?
Thanks
David
Can you do a "virtual directory" in your web server?
IIS: http://support.microsoft.com/kb/172138
Apache: http://w3shaman.com/article/creating-virtual-directory-apache
It's much like a CF mapping does for CF, but this on the web server level, making the mapped resources accessible via URL.
If you're talking about setting up your own CDN (content delivery network), then just setup another website simply to serve up all your graphics, scripts, CSS, swfs etc.

ASP.NET Virtual application having same look as Root application

I have a situation where I have several root applications that will reference the same virtual application. The root applications are the "branded" front-ends that are fairly light, with the virtual application doing most of the work.
I was planning on having the virtual application use the Master File of the root application by referencing it with a "/" prefix, but have found out the hard way that this isn't allowed.
I have seen options such as compiling the Master Page as a .dll but I don't think I can apply this to me scenario because the Master Page will be different for every root application.
Does anybody have any ideas on what I can do as an alternative? Is it possible to get creative with an inline Response.WriteFile call from the virtual to the root calling User Controls, or is there a downside to this?
Any ideas or assistance would be greatly appreciated. Thanks!
One way around this problem is to not create the virtual application as an application in IIS. By doing this, master page files from the root can still be used since there is only 1 app domain. The downside is that you will have to merge your "bin" folders together under the root.
I don't see a very clean way to do this other than what has been proposed by the other users.
Creative thinking:
Cheap hack #1:
One way would be to use mklink on the server to create a directory junction. Cheap but you could easily script it and both folders would get updated at the same time.
Cheap hack #2:
Have your master pages include an iframe to the shared vdir.

Resources