Deploying multiple ASP.NET MVC application in a single Virtual directory - c#

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

Related

Deploying an ASP.NET Web API service: precompile during publishing option, better activate it or not?

I have an ASP.NET Web API service. I have noticed that on Web Publishing Wizard there is an option called "Precompile during publishing". What does this option do? What is the impact by publishing with this option checked or unchecked?
I have googled and found this question. What effect does the new precompile during publishing option have on MVC4 applications?.
There it says:
If you have anything in App_Code, it will be precompiled into a DLL
before deployment. Without precompiling, this would happen on the fly
by the ASP.NET runtime.
Based on this I understand that If you have things in App_Code it is better to check this option, also I understand that performance increases, right?
There it also says:
If you don't have any files in App_Code and you want your site to
remain updateable, it doesn't seem to do much.
Where is App_Code folder? In my ASP.NET Web API REST project I do not have any App_Code folder. Instead I have App_Data (empty) and App_Start folders.
So in my case, as I do not have any App_Code folder, is it better to not check "Precompile during publishing" option?

Why can't I see the Controllers folder within my deployed MVC web app directory?

I have recently purchased a shared web hosting package, provided by GoDaddy, and deployed my own MVC web application to it.
My problem is that, when on the control panel (Plesk) provided by the host, I can't find the Controllers folder that contains all the behind code.
Is there a reason for this folder being hidden?
I'm guessing it's because the files within this folder are being used by the server all the time and can't be accessed/changed incase it f--ks everything up... But I am not sure about it because I am quite new to web hosting.
Thanks for any assistance in advance.
All your cs files including controllers will be compiled into DLL files. Please open "bin" directory to find all your DLLs.
When you deploy, u ll not get controller, because it contains c# code which changed to dll available inside bin folder.
Not Only Controller, the other folders which are having C# code like "App_Start"...and etc...will be changed to dll and will be available inside bin folder.
In the case of Model/s, if you are using Entity framework, then, the .edmx file will be available inside the Model folder.
All your Business logics including controllers, models and core etc are converted to dll and by Assembly name dll is created in bin (released or debug folder)

Is it possible to host a bin directory within an MVC application Areas folder?

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

Convert ASP.NET Web Application to ASP.NET WebSite

SCENARIO: A developer at work has created an three-tier ASP.NET Web Application which plugs into the company website, however the rest of the site was done as an ASP.NET Website. For clearity, his portion used Web Application (compiled into single .dll) and the rest of the site is WebSite (seperate .dlls). I do not wish to recompile the website every time a change is made to a page.
QUESTION: Is it possible to convert a Web Application
to a Website without rewriting the entire application?
TRIED:
Created WebSite and copied & pasted files over
Changed'CodeBehind' to 'CodeFile'
Deleted .designer.cs from pages and controls
Checked References
Ok - assuming you have a backup, this is how I would tackle it:
Delete the csproj file
From within Windows Explorer, delete any designer.cs files
Still in Explorer, create an App_Code folder at the root of the site
Find any *.cs files that aren't code behinds (eg., .ascx.cs or .aspx.cs) and move them into the App_Code folder
Open in Visual Studio as Web Site project
Verify .NET FX version
Change CodeBehind= to CodeFile= in any .aspx or .ascx files
Readd any 3rd party references
There's some potential complications around Global.asax, ASHX handlers (need to be inline) and referencing pages and controls. You'll have to deal with those manually, I'm afraid - but if it's a smallish effort, it should be easily doable.

asp.net mvc share content directory

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

Categories