Running an MVC Application as a Sub-Application?

 I'm attempting to create an MVC application as a sub-application to my standard Asp.Net Web application. Both of these projects are inside the same solution. While the parent application appears to be going fine, I'm having trouble getting the sub-application to work. After some massaging of my two web.configs, I was able to get the Asp.Net runtime to accept the configurations, but I have been unable to browse to any of the pages/controllers in the MVC application, including the root of the sub-application ("http://RootSite/SubApplicationName/"). I continually get 404's.

Actually, I do get a response when going to the url "http://RootSite/SubApplicationName/Home/Index/". It redirects me to index.aspx in that folder, and throws this error:

 The view 'Index' or its master could not be found. The following locations
 were searched:
     ~/Views/Home/Index.aspx
     ~/Views/Home/Index.ascx
     ~/Views/Shared/Index.aspx
     ~/Views/Shared/Index.ascx


The sub-application in IIS (7) is set up fairly straight forward: it's set to run in the same application pool as the parent app, which runs Asp.Net 2.0 in integration mode.

My suspicion is that I have something in the web.configs that is throwing it off. Are there things regarding, say,  HTTPModules or URL authorization modules, etc., that I should confirm aren't getting in the way of MVC?

Also, in the global.asax.cs file, should the default route be different? By default, the url parameter passed to routes.MapRoute is:

    "{controller}/{action}/{id}"

Should it be preceded by the name of the sub-application, like so?

    "SubApplicationName/{controller}/{action}/{id}"

I attempted a change like that, but it did not fix things.

Any ideas are much appreciated. Also, general information about setting up an MVC web application as a sub-application would be great.

Thanks.

0
Moskie
3/12/2009 10:15:21 PM
asp.net.mvc 4300 articles. 0 followers. Follow

4 Replies
1771 Views

Similar Articles

[PageSpeed] 12

 You'll need something like area's: http://blog.codeville.net/2008/11/05/app-areas-in-aspnet-mvc-take-2/

Currently, I'm working on an app that has all the mvc bits in a subfolder and with the area concept, everyting works fine. I did tweak the code a little bit to remove the hardcoded 'area' subfolder references, but that's quite easy to do.


Cuyahoga .NET website framework
My blog
0
Tijn
3/13/2009 8:26:20 AM

While that idea helps with the orgainization of an MVC application, I believe it doesn't address (what I think is) the difficult part of what I'm trying to do: run an MVC application as a sub-application within a standard ASP.Net application. It's more than just a certain orgaziation of controllers that I'm trying to get working.

0
Moskie
3/13/2009 4:21:11 PM

If this is IIS7 there should be no problem with running an MVC application as a Sub-application to an Asp.net standard application.

In IIS6 you will need to setup somethings to make this work.

You are correct that it is most likely something in teh web.config, if anything it will be in the parent applications web.config, which will be run under the sub ablications contexts so if your loading assemblies and the like that are in the parent bin the pathing will not be correct and you could get errors.

But as a test create a new blank Web Application, then create a blank MVC Application as a sub application and see what happens it will most likely work.

So since that will work, you can try it yourself. We can look to what happens before a site is initialized for a first time hit, that points to the run chaning of paretn web.config and global.asax, and then to the MVC web.config and global.asax.

90% of the time though its a problem at the parent application level.

 


Evan's Blog
Codeundrum: Code that puzzles.
0
Evan
3/13/2009 5:15:05 PM

This may be a long shot regarding your problems but maybe something to look at.

I have such a thing working on IIS 6.0. I created a virtual directory and used the wildcard mappings for routing.

What I ran into was a few http handlers stepping on each other, so in the MVC web.config I had to use the

remove tag for the handlers.

0
jwkygov
3/13/2009 5:45:08 PM
Reply:

Similar Artilces:

MVC application not running under IIS6
I've just installed the preview on Windows Server 2003. I've created a new MVC Application and it works fine with the build-in webserver. However, when I "publish" the application to clean virtual directory under IIS6, the website just loads with a blank page (since default.aspx is blank). Looks like the handlers aren't getting hooked up correctly. Is this the expected result? Any idea how to fix it appropriately? Andrew Hi Andrew, With IIS7 you can just rely on the URL mapping features of the server to map the MVC file type.  With IIS6 you can do ...

VB.Net
Hi guys, hoping that you may be able to help me on this one. Is there anyway I can run a Console Application, from a button click (or similar) within my windows application. I am using VB.Net in Visual Studio 2005. Any help would be great. ThanksPhil This is an ASP.NET forum. For better responses refer to the winforms forum at MSDN http://forums.microsoft.com/msdn/default.aspx?siteid=1What you can do is launch a process that targets the executable file for the console application.  Hey, thanks for getting back to me - I am going to try calling in a batch file to run the con...

HttpWebRequest
 Hello,I don't understand why this code works on a console application, but not in a Web Application (in particular a ASP NET MVC application)...(the URL returns a JSON file).. I have a WebException Exception (Error 400 : bad request) string url = "http://nvmodules.netvibes.com/widget/json";HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);myRequest.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;using (HttpWebResponse myHttpWebResponse = (HttpWebResponse)myRequest.GetResponse()){</p><p>StreamReader r = new StreamReader(myHttpWebRe...

How to Run my .exe file or Application in the Background using .NET Application like explorer.exe file is Running always in the Background...(you can see in task Manager..)
Hi , This is Sundar , i want to develope one small Application in windows or web ,that should send the mail continiously according to at what time scheduled in the application and that should Running in the Background always like windows service,SQL server ........ so , please help me ......................  what;s the problem if you develop an windows service and install it in your system.  http://www.15seconds.com/issue/021007.htmGive a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.  see, i have created the Windows services and wh...

Problem running the MVC application from IIS
Hi, I have an MVC app. which runs fine thru VS. But when run thru IIS (IIS 5.1), throws some errors. When run thru VS the address I get in the address bar is, http://localhost:1341/MVCApp/DisplayPage/12 When run thru IIS the address I get is, http://localhost/MVC/MVCApp/DisplayPage/12 MVC is the name of my virtual directory - I seem to understand something. But stuck with the solution - What should I do here? Pls help. Thanks in advance. Sangeetha Have you mapped .mvc extension to ASP.NET ISAPI filter? i guess thats your problem. you can get how to do it here. else follow this lin...

Application to Application
Hi,  Curious on what different solutions there are for one application that is closing down to contact another application. I have the closing down applicaton sending something to the database and for the other application to monitor the database records, but I think that is a horrible solution. Another idea would be when the closing down application sends a message to the database for the database to then respond by sending a message to the other application, but that means the database would have to know where the other application is.  If possible, the security issue mak...

Getting error when running sample mvc application.
Hi, I have just created new mvc web application (MVC beta version), and when I run it. I am getting following error:  Could not load type 'System.Web.Routing.StopRoutingHandler' from assembly 'System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Can any one suggest, what should I do to resolve it. Thanks.    Hey there, MVC Sample application? What do you mean by that? Where did you download that from? most examples out there are out of date, because of the latest updates.Can you be more specific? regards,...

Can I upgrade vs 2005 web application to vs 3.5 MVC application?
H, Can I upgrade vs 2005 web application to vs 3.5 MVC application? I already have site running http://mysite, which is developed in vs 2005 C#. But after learning MVC 3.5, I want my site to use this architecture. Is this is possible? Or I need to write the code again.  Please help me out here...ThnaksShikhar Dadhich I am!... all because of .NET Hi Shikhar To use MVC, you will need VS 2008 or Visual Web Developer 2008 Express Edition with SP1. VS2005 is not officially supported. As for converting the site, this blog post might help as it describes approaches others have used whe...

MVC application doesnt run under IIS 5.1
Hi, Please help me. I am trying to run my MVC application using preview 2 under IIS 5.1. I registered the ISAPI.dll and put up .mvc in my global.asax file. But still i get a page not found. I even tried to run a clean new MVC preview 2 application under IIS 5.1 but that also gave the same problem(only default.aspx runs fine, but as soon as you click on 'home' or 'about' you get the page not found error). What is the thing I am missing here?  Did you map .mvc extension to the ASP.NET isapi filter?Want to learn more about ASP.NET MVC? Pre-order (USA or UK)"Beginning...

Running dasBlog 2.1 underneath an MVC application
OK, I'm just going to post this quickly, hoping someone has already attempted this and knows exactly what to do. Scenario is as follows: Shared hostingIIS 7 running in Integrated mode (I could switch to Classic if desired)root site: Runs an ASP.NET MVC application./blog/ - runs dasBlog 2.1. Is set as its own 'application' is IIS. Runs on the same app pool (shared hosting/can't change this)The summary of the problem is that the MVC application is interfering with the /blog/ application. I've gotten it working just enough that dasblog will load aspx pages...but now wil...

Visual Web Developer Express and Sub Folder Applications (Application within an Application)
How do I set a subfolder to be an application in Visual Web Developer? I cant seem to find the setting. (I can change it in IIS however relative links arent being created properly in Visual Web Developer)Any help is appreciated.Z...

Application as Service is an advanced system utility which lets you run any application as Windows 2000/XP/2003 Service at system boot. Specify application priority, run your program without the need
Application as Service is an advanced system utility which lets you run any application as Windows 2000/XP/2003 Service. You can easily configure Application as Service using its intuitive GUI interface or command line configurator directly from your software. Application as Service features very low CPU usage, custom environment variables, monitoring and detailed logging as well as many other features. You can use Application as Service software to: Launch any application as Windows 2000/XP/2003 service at system boot, before user logon; Automatically start applications before and after ser...

Using .net AJAX enabled application in non .net Web Application
Hi,Does anyone have similar experience in development?  I want to check if it's possible to run .net ajax object (from one standalone .net framework platform in company) with non .net application (i.e. J2EE web application)?  It is because we want to add certain feature (i.e. office communicator chat) to our exist application (oracle J2ee). Please give me some advice :) Thanks! Hi, .Net AJAX is based on .Net Framework architecture. Thus .Net Framework currently lacks support for other platforms, such as Java. Please check this link: http://www.csharphelp.com/arch...

SQLCA works when application runs in PB not when application is run with Powerbuilder WDK.
Hi, My applications with out SQLCA run great through Powerbuilder WDK, my applications that contain SQLCA information doesn't. When I run the application in PB I get a splash screen and then the application starts. When I run it through PB WDK the splash screen starts and the I get a login box. No matter what I do it always show's up and when I hit OK I get the following SQLSTATE = 08001 error. How can I stop this from occurring? The SQLCA code and ini file are below. code: startupfile = "pds.ini" /* Populate sqlca from current PB.INI settings */ sqlca.DBMS...

Web resources about - Running an MVC Application as a Sub-Application? - asp.net.mvc

Resources last updated: 2/10/2016 11:10:22 PM