I have 50 SAME asp.net websites hosted on IIS. Something like WordPress, where each website though same has different content.
C:\inetpub\vhosts\website1.com
C:\inetpub\vhosts\website2.com
C:\inetpub\vhosts\website3.com
.
.
.
C:\inetpub\vhosts\website50.com
Since these are exactly same copies of the ASP.NET website; I want to use a 'common' bin folder so that I don't load 50 copies of the same set of DLLs to update and load in memory each time.
The solutions here: Is there a way to change .net mvc bin dir location? DO NOT work as I want the DLLs to be placed outside the website folder, so that they can be shared.
One little detail you should know about IIS and ASP.NET; they do not actually run the files in the bin folder. Rather, they copy the files in the bin folder into a "shadow directory" (something like "C:\WINDOWS\Microsoft.NET\Framework\v4.5.XXXX\Temporary ASP.NET Files"). It is from there that they are actually executed. The bin folder is monitored for any changes, and the shadow directory is updated as needed. This allows you to deploy new DLLs even when the site is running-- otherwise, they'd be locked.
So... no matter what you do, the O/S is going to load multiple images of the same DLL, even if you get them to all use the same bin folder. As far as I know there is no way to turn this off.
That being said, if you want to save a bit of disk space and get your sites to use a common bin folder, consider using a symbolic link. This essentially allows you to create a directory that "points" at another directory (this sort of thing is more common in Unix). Thus you end up with one copy being accessed from several places. Just one word of caution: be very careful when deleting things, because you could delete folders from all 50 of your sites without meaning to.
But a better option (depending on why you are running 50 identical sites, which is very unusual) is to run just ONE site, with one IP address, but with several DNS entries pointed at that IP. This way it would look like you have 50 sites when you only have one. The trick here is (if you are using https) you'll have to use host headers to pick the SSL cert so that browsers don't show a phishing warning. Or, if your site is load balanced, you could terminate SSL at the load balancer (a strategy known as SSL offloading) so that a cert at the IIS level isn't even needed.
Related
I understand this folder App_Data is normally for database files etc but I want this now for images, the idea being users upload images into this folder and they can be accessed from the website, I basically want App_Data to be used/thought of as a normal folder now, anyone know how to do this? Is it just permission settings or can this folder not be used like a normal folder. Thanks in advance :)
ApplicationData is a folder for Application Data. What kind of data you store there is up to you. Note that there are 3 on a Windows:
ApplicationData
CommonApplicationData
LocalApplicationData
Generally data in there it should be data specific to this user - except for CommonApplicationData, of course. Being shared across users, is what the "Common" Prefixed Folders are there for.
However the rest of the question makes no sense. You want the user to manually put stuff there, so a WebSite can upload it? You also seem to think it is somehow not a "normal" folder?
WebSites do not have random access to the file System. So it would really just be annoying for the user to navigate there. And if there is another programm in the loop, you have not told us of it.
And the folder is quite normal. The OS stores a path to it wich can be changed (and the file moved Automagically), but beyond that it is as normal as can be. The unknown position is why you should always retreive the real values from the OS with https://learn.microsoft.com/en-us/dotnet/api/system.environment.specialfolder
Edit:
Based on your comment, I understand now. You are writing a Website. And you wonder why the server has no access to the AppData Folder. Of course only now I noticed MVC properly.
WebServers are uniquely vulnerable to hacking. Online 24/7, a few well known frameworks and widespread reachability as a core goal. As a result they generally run under the most restrictive userrights possible.
Read access to the servers programm and the Instances content directory - any more can not be expected and should never be granted. Maybe write access in a subfolder of content for Temp files - but there are better solutions, that involve Databases and HTTP Handlers.
Solution:
If you want your images to be avalible, put them into a subfolder of the Content directory for this instance. However you really should be considered Database Storage with HTTP Handlers: https://www.red-gate.com/simple-talk/sql/learn-sql-server/an-introduction-to-sql-server-filestream/ Some even go as far as having a seperate, dedicated Webserver just for Images. But I doubt you are on that scale yet.
I've got a ton of DLLs used by my website. Most of them never change, but I frequently change 1 of them.
Every time I do the site is down for about 5 minutes while IIS restarts. I'd like to reduce this.
I've read about shadow copying being slow when you have a lot of DLL files so I'd like to disable it in most cases, but I do want to use it on my frequently modified DLL so I can change that without having to stop IIS.
The documentation on shadow copying seems to presume you are setting it up before the AppDomain is created, but IIS handles the creation of the AppDomain so I don't know how to use the AppDomainSetup.ShadowCopyDirectories property to tell it not to do any shadow copying in the main /bin folder and only shadow copy things in the /bin/changesFrequently folder. Can I set this in web.config somehow? Is there a way to run c# code in IIS before the shadowcopy process starts?
Quote from the Azure Web Jobs Documentation:
Persisted files
This is what you can view as your web site's files. They follow a
structure described here. They are rooted in d:\home, which can also
be found using the %HOME% environment variable.
These files are persistent, meaning that you can rely on them staying
there until you do something to change them. Also, they are shared
between all instances of your site (when you scale it up to multiple
instances). Internally, the way this works is that they are stored in
Azure Storage instead of living on the local file system.
Does that imply that by dropping app_offline.htm into the site root folder should pretty much bring down all instances simultaneously?
Yes.
It doesn't bring them down exactly just redirects all traffic to that htm file.
And it's easy to try for example using Visual Studio Online editor:
http://dotnet.dzone.com/articles/first-look-visual-studio
Or the DebugConsole:
http://azure.microsoft.com/blog/2014/03/04/windows-azure-websites-online-tools-you-should-know-about/
Just add the file to wwwroot and browse to your site.
I have 3 differnt websites on same webserver under a root directory. A lot of the code is the same across all 3 websites.
I wanted to see if there was a way to move code from all 3 websites up one level (outside the website itself) to the root directory (where the folders for each website are contained.
EX. The root directory is c:\ (where i want to move the files to and access from each indivual website. The websites themselves are contained in c:\Website1, c:\Website2, etc.
So is it possible to move code from c:\Website1 to c:\ and access it from c:\ in the c:\Website1 website?
If you need more details or I am not clear let me know.
Thank You.
I recommend putting the library DLL in the GAC.
Consider this: what if you need to update the library DLL to support new features for one site, but this introduces incompatibilities with the other sites? The GAC supports multiple versions of the same assembly, so you can update the web sites separately, if desired.
Depending on what you are trying to accomplish placing them inside of a dll may make since. I would advice placing those in folder: c:\libs\ and then you could access it via: ..\libs\
I have a little payments webApp, our customers can install it on their IIS and work with it. They can upload their own logotype.
We are using WyBuild to update this apps, but it replaces all files on the web folder with the new version, so the logotypes are deleted, that's why we placed the customer's files in program files, so the updater can't delete them.
the problem is that I can't load the images from the following path
C:\Program Files\MyApp\ImageFoder\logo.jpg
I don't know how to do it and I'm almost sure that is not possible to load
My web application is on
C:\inetpub\wwwroot\MyApp\
I can't have the images on the webFolder because wyBuild deletes them when I'm trying to update them, I already tried the paths like this: (the don't work)
///file:c:/program files/ .... etc
so, the question is
How can I load an image to an asp:image control using it's windows path ?
You need to configure an IIS Virtual Folder to point to the alternate location where the images are stored.
I wouldn't put them in Program Files, though, a sibling folder in wwwroot would be better.
Remember NTFS permissions are easy to mess up and it's easier to manage them in a single place.
Update - for locally installed, localhost-only sites Alternatively (and this is only a good idea if you have minimal amounts of traffic. NOT for public websites), you can serve files from an arbitrary location using a VirtualPathProvider. It sounds like this 'web app' is installed like a desktop app for some reason? If you want to store user data externally, the user's App Data folder would be appropriate, but ONLY if the web app refuses external connections, and can only be accessed from the machine.
Since you're dealing with images, I'd grab the imageresizing.net library and use the VirtualFolder plugin to serve the files dynamically. It's 200KB more in your project, but you get free dynamic image resizing and/or processing if you need it, and you save a few days making a VirtualPathProvider subclass work (they're a nightmare).
Wouldn't it be better to use isolated storage?
Added: I mean on the users machine, and upload them again if they are not found. This takes away your overhead completely.