Would it be possible in .NET Runtime 4.0 or 3.5 to have a website that was both an umbraco website and an MVC website in one?
Why would I want this?
To take advantage of BOTH Umbraco AND MVC. Now to be clear, I don't want MVC In umbraco, so waiting till 5.0 is not going to cut it. I want a website that is partly managable Umbraco (this would be all the content that the administrators enter. Static text such as About, and (I imagine) also the master templates will be edited from Umbraco.
However, I don't want a node for each user submission, so the part of the website that gets really 2.0 would reside in another MVC Website Application that preferrebly referenced the umbraco master template. The MVC Web 2.0 part of the website would be hooked of to a LINQ 2 SQL dataContext through a Repository pattern, so it might also be hooked up to a different database than Umbraco.
So to distinguish:
The Umbraco Websites' job is to deliver static organization-mantained content The MVC Websites' job is to deliver dynamic user-maintained content
Is this doable, or will I be looking at an ugly fix?
You can easily run webforms and MVC side-by-side so this shouldn't be a biggie. It's all about ensuring that the different routing rules from the two systems doesn't conflict. Umbraco likes to be in charge of all requests, but in web.config you can tell it to keep out of specific urls/directories.
So working in visual studio would you create two projects? I'm having a bit of trouble working them together namely because of the routing. When i try to debug my MVC site i get an error saying that Default.aspx maps to another application which of course is the Umbraco website.
Physically I have a clean runway umbraco installation (with the solutions template add-on which btw. works just fine) located in inetpub\wwwroot, and my Mvc Website is at in a whole different directory outside inetpub
so where I'm at now is that I have a virtual directory created for the mvc sub app, but I'm getting a
Could not load file or assembly
'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system
cannot find the file specified.
error message. I've tried several solutions. Both removing the umbraco references in the httpModule, and using the location tag to prevent the inheritance of system.web configuration. Which leaves me kind of dazzled because everyone else seems so have their problems fixed by those solutions.
[FileNotFoundException: Could not load file or assembly 'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system cannot find the file specified.] System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName) +0 System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +64 System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +58 System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +65 System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +342 System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +52
[ConfigurationErrorsException: Could not load file or assembly 'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system cannot find the file specified.] System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +351 System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +56 System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +146 System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1219 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +97 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +188 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +295 System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr appContext, HttpContext context) +56 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +231
[HttpException (0x80004005): Could not load file or assembly 'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system cannot find the file specified.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8894031 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +333
problem is that if I use a regular folder I get an error because I have sections in my Mvc web.config that require the folder to be at application level:
Parser Error Message: It
is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS.
Source Error:
Line 56: ASP.NET to identify an incoming user. Line 57: --> Line 58: <authentication mode="Forms"> Line 59: <forms loginUrl="~/Account/LogOn" timeout="2880" /> Line 60: </authentication>
I've noticed your activity in some of the other Umbraco MVC threads. Have you had any luck implementing it this way?Creating it as an application unfortunately leaves me with the first error I posted. I get the UrlRewrite assembly error.
My reservation was only due to the fact that I thought it was a bit hacky tapping into that, and I would like for performance sake too, not to reroute in that way, but perhaps that's the only way to go for me?
I was trying to do the exact same thing as Jakob for a client I'm working with and I finally got it to work with Umbraco 4.7 and .NET MVC 3. I turned the subfolder containing my MVC application into its own IIS Application. Then, I encapsulated <system.web> AND <system.webServer> AND <system.web.webPages.razor> with the <location path="." inheritInChildApplications="false"> </location>. I now have Umbraco 4.7 completely functioning with an ASP.NET MVC 3 Application running in a subfolder and everything works. The key was to encapsulate the web config in 3 places and not just one. (before that, I was getting ALL the same errors that were posted here). I'll post a guide within the week with a step-by-step on how I got it to work if anyone's still interested (I know this thread's mostly dead, but it still shows up high in Google, so I figure people are probably still reading it, if not commenting).
This last week, I also managed to share templates (master pages) between the MVC 3 and Umbraco sites. It's not quite as easy as I thought, but I worked out a solution and can post a tutorial on that within the week if anyone's interested.
Sorry to bother you Scott but did you have the time writing a tutorial about sharing the templates between mvc 3 and umbraco? An overview on your approach will suffice.
The best solution we found was to do an html scrape of sections (ie. head, header, footer, etc.) of an umbraco page and pulled that into our .NET application's master page. I'll be posting a tutorial on it later this week and will copy the link here.
Sorry to restart this thread. I used Scott's solutions above on a 4.7.1 site. After wrapping the <location> around <system.webServer>, my MVC application works, but then trying to log into umbraco causes a "500 Internal server error." Any ideas on how we can have the best of both worlds?
Can you provide me some details about sharing templates (master pages) between the MVC 3 and Umbraco sites? If you already have a tutorial, the link should be fine.
Umbraco Website And MVC Website In ONE
Would it be possible in .NET Runtime 4.0 or 3.5 to have a website that was both an umbraco website and an MVC website in one?
Why would I want this?
To take advantage of BOTH Umbraco AND MVC. Now to be clear, I don't want MVC In umbraco, so waiting till 5.0 is not going to cut it. I want a website that is partly managable Umbraco (this would be all the content that the administrators enter. Static text such as About, and (I imagine) also the master templates will be edited from Umbraco.
However, I don't want a node for each user submission, so the part of the website that gets really 2.0 would reside in another MVC Website Application that preferrebly referenced the umbraco master template. The MVC Web 2.0 part of the website would be hooked of to a LINQ 2 SQL dataContext through a Repository pattern, so it might also be hooked up to a different database than Umbraco.
So to distinguish:
The Umbraco Websites' job is to deliver static organization-mantained content
The MVC Websites' job is to deliver dynamic user-maintained content
Is this doable, or will I be looking at an ugly fix?
hey,
I think it would be do-able, but how easy it would be to integrate (master templates) I don't know.
I do know that v5 will allow the use of mvc apps in place of user controls but that is a way off
Either way it sounds interesting and I will be interested to see how you do as I have similar ideas ;-)
jay
You can easily run webforms and MVC side-by-side so this shouldn't be a biggie. It's all about ensuring that the different routing rules from the two systems doesn't conflict. Umbraco likes to be in charge of all requests, but in web.config you can tell it to keep out of specific urls/directories.
So working in visual studio would you create two projects? I'm having a bit of trouble working them together namely because of the routing. When i try to debug my MVC site i get an error saying that Default.aspx maps to another application which of course is the Umbraco website.
Physically I have a clean runway umbraco installation (with the solutions template add-on which btw. works just fine) located in inetpub\wwwroot, and my Mvc Website is at in a whole different directory outside inetpub
so where I'm at now is that I have a virtual directory created for the mvc sub app, but I'm getting a
Could not load file or assembly 'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system cannot find the file specified.
error message. I've tried several solutions. Both removing the umbraco references in the httpModule, and using the location tag to prevent the inheritance of system.web configuration. Which leaves me kind of dazzled because everyone else seems so have their problems fixed by those solutions.
jeg poster lige stacktrace
I think you should just put your mvc app in a regular folder, so you have a root like this:
wwwroot
- bin
- config
- css
- umbraco
- (and so on)
- YourMvcAppHere
- web.config
- default.aspx
Then you add your own folder to the web.config
I have not done any MVC stuff myself, but this is the way I would start out.
Have you tried using the <remove /> element in you MVC web.config file to get rid of the urlrewriting module?
Thank you for your reply :)
problem is that if I use a regular folder I get an error because I have sections in my Mvc web.config that require the folder to be at application level:
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Source Error:
To overcome this, go to the IIS manager and mark that folder into an application. That should do the trick nicely for you I think.
HTH,
Peter
Hi Peter
I've noticed your activity in some of the other Umbraco MVC threads. Have you had any luck implementing it this way?Creating it as an application unfortunately leaves me with the first error I posted. I get the UrlRewrite assembly error.
Thanks for the notion though :)
and just to be perfectly clear I've tried both <clear/>, <remove name="UrlRewritingNet.UrlRewriter" /> and
<location path="." inheritInChildApplications="false">
<system.web>
...
</system.web>
</location>
Maybe I should just go with this approach anyway http://memoryleak.me.uk/2009/04/umbraco-and-aspnet-mvc.html
My reservation was only due to the fact that I thought it was a bit hacky tapping into that, and I would like for performance sake too, not to reroute in that way, but perhaps that's the only way to go for me?
Hm, I missed your initial attempt, hence my reply ;)
Your wrong about me participating in other MVC-topics though.....I've not worked with MVC yet....
Perhaphs Niels has some idea to get it working
Peter
Yeah, I think I mistoke you for Dirk. Shame on me ;) No prob. Valid input anyway ;)
Figured this one out FINALLY!
I was trying to do the exact same thing as Jakob for a client I'm working with and I finally got it to work with Umbraco 4.7 and .NET MVC 3. I turned the subfolder containing my MVC application into its own IIS Application. Then, I encapsulated <system.web> AND <system.webServer> AND <system.web.webPages.razor> with the <location path="." inheritInChildApplications="false"> </location>. I now have Umbraco 4.7 completely functioning with an ASP.NET MVC 3 Application running in a subfolder and everything works. The key was to encapsulate the web config in 3 places and not just one. (before that, I was getting ALL the same errors that were posted here). I'll post a guide within the week with a step-by-step on how I got it to work if anyone's still interested (I know this thread's mostly dead, but it still shows up high in Google, so I figure people are probably still reading it, if not commenting).
hii Scott McCown, plz post the stepe by step guide how u got it work umbraco and mvc. Is this acn be done with umbraco 7 and asp.net mvc 4.
Hey Scott,
I'd be very interested to get the details about this :-)
Cheers,
Michael.
Scott,
+1
Yes, people are still looking for answers to this. I was thinking to do the same thing. Any help is greatly appreciated.
Sorry it took me so long to get this up. It was crunch time at work, so I just barely got a chance to write up a tutorial. It's on my blog at http://scottsdevblog.com/2011/07/adding-an-mvc-or-other-net-application-in-umbraco-cms-4-7/
This last week, I also managed to share templates (master pages) between the MVC 3 and Umbraco sites. It's not quite as easy as I thought, but I worked out a solution and can post a tutorial on that within the week if anyone's interested.
Sorry to bother you Scott but did you have the time writing a tutorial about sharing the templates between mvc 3 and umbraco? An overview on your approach will suffice.
@Valentin
The best solution we found was to do an html scrape of sections (ie. head, header, footer, etc.) of an umbraco page and pulled that into our .NET application's master page. I'll be posting a tutorial on it later this week and will copy the link here.
Sorry to restart this thread. I used Scott's solutions above on a 4.7.1 site. After wrapping the <location> around <system.webServer>, my MVC application works, but then trying to log into umbraco causes a "500 Internal server error." Any ideas on how we can have the best of both worlds?
@Doug I've not had to do that, I followed this post by Aaron: http://www.aaron-powell.com/umbraco/using-mvc-in-umbraco-4 and it's follow-up: http://www.aaron-powell.com/umbraco/using-mvc-in-umbraco-4-revisited
Scott,
Can you provide me some details about sharing templates (master pages) between the MVC 3 and Umbraco sites? If you already have a tutorial, the link should be fine.
Thanks.
is working on a reply...