At this moment I have 2 project that use the same content directory (scripts, static html, images etc etc). Is there a way to share this directory between the two projects instead of maintaining both duplicate directories?
When I publish one of the projects it needs to include that directory.
The two options that come to mind are mapping a static asset folder as an application within the website in IIS, or creating a virtual path provider.
Some VPP related links:
http://weblogs.asp.net/scottgu/archive/2005/11/27/431650.aspx
http://www.codeproject.com/KB/aspnet/Virtual_Path_Provider.aspx
http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx
Related
We have an Application that has lots of subfolders (each one compiled up in separate projects in VS as classes)
When you first load up the .sln file it is creating the virtual folders etc, but it is adding an application for each subfolder which prevents our code working. As it is expecting it to be one application so we have to go through the folders removing the applications added in error.
Each subfolder has a web.config that contains the configuration for the entityFramework and other required links, could this be why it is being added as an application?
in Summary:
Why are these applications being automatically added?
How can we stop them being added automatically?
I have an MVC 4 application that hosts other MVC applications within the Areas folder of the main application:
Web UI
Areas
Application 1
Content
Views
Application 2
Content
Views
Bin
MainApp.dll
Application1.dll
Application2.dll
Config
Views
Lib
Images
Other top level application folders
These applications share have their own set of dependencies which all currently reside in the main bin directory. This has caused us issues whereby one application requires a newer version of a package forcing me to upgrade the package within the second application. In my mind a resolution to this would be to isolate the dependencies by having a bin directory within each folder within the Areas folder which could contain the different versions of dependencies:
Web UI
Areas
Application 1
Bin
Application1.dll
DependencyV1.dll
Content
Views
Application 2
Bin
Application2.dll
DependencyV2.dll
Content
Views
Bin
MainApp.dll
Config
Views
Lib
Images
Other top level application folders
Aside from the risks of running multiple versions of dependencies - is this possible?
You can't do what you want to do.
If you have several apps in your areas, in term of project it's still a single app, so you only have one bin folder.
IIS may allow you to deploy several apps in Virtual directories, but you need to separate your areas (one VS project/csproj per app).
You deploy each app in a different folder, and in IIS you configure the website to the root app, and you right clic on it to add other applications
Normally an ASP.NET MVC application can be deployed by placing the application folder in the virtual Directory.
The application folder contains
bin folder
Scripts Folder(If needed)
Views folder
Global.asax file
web.config file
But, I want to place the bin folder outside the application folder so that I can deploy more applications in a single application folder. All applications share the bin folder and session also get shared.
What I want to do
..Virtual Directory
..\bin
..\App1Name\App1Contents
..\App2Name\App2Contents
..\App3Name\App3Contents
..web.config
I already achieved this for web application with web forms without Global.asax file. But in MVC application I am unable to shared the bin folder.
How to achieve it?
Where I need to place the Global.asax file?
How the route all the applications with bin folder placed outside the Applications?
Thanks in advance
This is not possible. You were able to achieve this with Web Forms because each individual page is in effect it's own application. However, MVC works differently. Many factors, not the least of which is the routing framework, requires that the web application be secluded. You cannot deploy multiple MVC applications to the same document root. You can deploy a second MVC application to a virtual directory within the first, but be advised that the web.config of the outermost application will affect the inner application as well.
Based on the fact that your applications are sharing common binaries already, you may want to look into using MVC Areas to facilitate a logical separation between applications (but have them all as part of a single application). The following link describes this in more detail: MVC Areas
Can we have multiple web.config files in a single project in c#?
if yes then what is its benefit?
Say I have a project ABC that has three folders under it.
Now ABC has its web.config file, so does each folder under ABC.
so there are total 4 web.config files.
So what will be the output when I run the project?
Yes you can have multiple web.config files in the separate folders. They can be used to enable/disable modules on a per folder basis. You can even set up each of those folders as separate web sites, even sub-sites, that use some modules from the parent web.config and some from the sub-site web.config.
I wrote up a blog post in the past about using BlogEngine.NET as the main site and configuring the web.config file in sub-sites. It might be of some help to you: http://markschlegel.com/post/2011/11/26/BlogEngineNET-a-sub-site!.aspx
Sure you can. An example of what this is used for is the default MVC 3 project template. There is one web.config for the site, and there is one inside the Views folder to deal with rendering the views.
Yes you can. The ASP.NET MVC project templates do this to restrict browsing the Views folder.
I would like to have App_LocalResources folder outside web application folder, so that I could deploy updated resx files and web app. independent of each other.
Reasons: We do not want to change current deploy tool.
Any way to achieve this?
Way the default resource manager works in asp.net is it picks the resex entries for the respective aspx file from the App_LocalResources folder in the current directory. As far as I know this behavior is not something you can configure (i.e to ask it to pick entries from a different folder!) But there is a workaround, that you could implement your own Resource Manager and let it picks entries from a location you specify it to. Found this and this while googling. Hope that helps.