IIS Config file in virtual directory - iis

I have multiple websites that all have the same code, but different app settings.
I want to place my app settings in a separate configuration file that is located in a virtual directory. This will allow me to have a single copy of all of the code shared across all of the sites with a different virtual directory for each site.
Unfortunately, when I try to configure this, IIS doesn't process the config file when it is in a virtual directory.
If you have a solution to this, I would appreciate your help.

Maybe using the machine.config file on your web server would be a suitable alternative? Otherwise you could create a web.config file in a global folder somewhere and open it using the WebConfigurationManager.OpenMappedWebConfiguration() method.

It's not possible to use a virtual directory (or even files outside of the current website; only the current folder, or a sub-folder).
One possible way to share setting across projects would be to do it at build-time - either by coping it in, or using a Linked File in VS to have it copied to the folder on publish.
If you really need this functionality on the server, you could try (though I can't say how well it would work) a Junction.

Related

Shared files & virtual directory persmissions on IIS

getting myself in a twist here, trying to set up a directory on one website to store a number of files that need to be accessed as include files by a number of other websites in the same server (IIS).
I've created the directory on the main website, and then virtual directories on the other websites, all with paths set to that.
www.mainsite.com/cdn/test.asp ... opens OK
www.othersite.con/cdn/test.asp ... opens the test file on the mainsite as well
But when I try to use an include (virtual or file) it can't find the test file.
Using FileSystemObject / DirectoryExists function can locate the main cdn folder, mapping the path from the virtual folders.
But it doesn't recognise the file in that folder?
Any ideas on making this work... or suggestions for a better way to do it would be much appreciated!
Thanks
Matt

Possible to use Virtual Path to an external disk on Plesk Managed Windows server?

After getting a helpful answer from this post I want to store media on a separate harddrive on the windows server. Is it possible to make those files available via http?
I soon discovered that Plesk does not allow me to create a virtual path that points to a location outside of my website root. I want the virtual path to point to a folder on D: (an extra disk, not the same as the website root directory)
Only two possible solutions I could think of, although I can't find them any where.
1) Maybe plesk has an advanced configuration file that prevents it from overwriting certain things in IIS when it runs its maintenance jobs or updates, specifically the Virtual Path I created directly in IIS outside of plesk.
2) Maybe there is a third party component available that offers this functionality, setting virtual paths outside of web root or the config file I just mentioned in #1.
Any other solutions are also welcome.
cd "%plesk_vhosts%\"domain.tld\httpdocs
mklink /J point c:\outOfSpace
Now provide permissions to "psacln" group to c:\outOfSpace and that's it.
Also you can create "point" not in httpdocs but in web space root and than from Plesk create Virtual Folder inside /httpdocs with needed access permissions.
There is issue that your custom permissions may lost after Plesk upgrade, this KB article describe how your can avoid it kb.sp.parallels.com/111194

How to setup IIS 7 using physical path directing to DropBox?

I'm using multiple computers for development and I want to be able to store my files in my dropbox folder. I went to change the physical path in IIS from c:\inetpup\wwwroot to the dropbox folder but I get this error:
The requested page cannot be accessed
because the related configuration data
for the page is invalid.
I couldn't find the config file so I was wondering if anyone had done this before or whether there a better way to sync everything nicely across several PCs?
I tried it (IIS 7.5, Win 7) and it should work just fine to let your physical path of your web look at your dropfox folder. I would guess your web.config file generally contains malformed XML (see KB942055).
I'd suggest, try to map it to an empty folder just with an index.html file and see if this error still occurs.
As a workaround, I guess you can put Dropbox in your wwwroot folder and set up a virtual directory that points to Dropbox. However, there are some security issues that may hinder you from doing so. I come across a nice tutorial on how to set up Dropbox to IIS as FTP Publishing. Hope it helps.
Hodgin's guide on using Dropbox as FTP publishing.

Exporting IIS configuration

Windows 2003/IIS 6...
I have a virtual directory on a web site that closely mirrors the configuration another virtual directory on the same site will need. Since we have multiple dev/staging/test/prod environments, I'd like to be able to export the values of one virtual directory and quickly fire one up on either the same machine (with a different name/source directory) or on another machine (with perhaps the same name/source directory).
Can that be done? I see you can export the configuration through the IIS manager, but it seems to have a lot of keys embedded in it and I'm not sure if that can be directly imported into a separate entity on the same/different machine, or if it's only used for backups in case the original gets corrupted and needs to be restored.
You may want to take a look at the sample VBScript files installed with IIS 6. On my system they are in C:\Windows\System32
Two in particular seem relevant to your question:
iisvdir.vbs - allows listing, creating, and deleting virtual directories locally or remotely.
iiscnfg.vbs - allows exporting configuration for copying to another machine.
Neither one of these does exactly what you want, but it looks to me like they could be used as sample code to help you get to where you want.
Have you taken a look at the IIS6 Migration Tool yet? It may address your needs.

How to host multiple webapps using only 2 Virtual Directories

my shared hosting only allows me to create 2 virtual directories. and i want to host multiple webapps... say an asp.net mvc blog, a forum, a personal site etc...
isnt there any other way of doing this? cant i simply just ftp the blog folder to one of my virtual directories and then access it online??
For ASP.NET web applications, typically each would live in its own virtual directory which serves as the application starting point.
Technically you could "piggy-back" two applications on the same application starting point in one of two ways:
Put all the files for each application in the same directory (and appropriate sub directories)
If you don't have ANY files that overlap, you can get away with this. Of course, it's likely that you won't with such files as the default or index pages, etc. And this would be pretty messy anyway.
Put all the non-binary files for each app in an appropriate subdirectory and the binaries in the main virtual's \bin directory.
You'll be able to do this only if each application's binary files don't overlap by name AND there are no namespace ambiguity conflicts between assemblies (two different assemblies by file name, but with the same namespace). The latter is much less likely to happen if you are trying to piggy-back two different applications.
The big problem I see with the latter solution is that any parts of the application that make use of application root references will break. When some code tries to resolve a reference to some resource (like an image) based on an application root reference such as
~/images/logo.gif
the ~ will get resolved to the virtual directory, but will not include the additional (non-virtual and non-app starting point) subdirectory in which the application lives. So instead of this:
/vd1/app1/images/logo.gif
you'll end up with this:
/vd1/images/logo.gif
Obviously, that won't work.
So... you won't break either app if you can put them both in the same virtual directory, however, you'll have to check for file conflicts and such. Possible namespace conflicts will be unavoidable without separate application starting points.
Can't you just put each app in a separate subdirectory in either of the virtual directories. e.g. if you had http://server.com/vd1, you could partition it like http://server.com/vd1/app1, http://server.com/vd1/app2, etc.

Resources