Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jakob 38 posts 54 karma points
    Jan 30, 2010 @ 21:27
    Jakob
    0

    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?

  • jaygreasley 416 posts 403 karma points
    Jan 30, 2010 @ 21:48
    jaygreasley
    0

    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

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Jan 30, 2010 @ 22:19
    Niels Hartvig
    0

    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. 

  • Jakob 38 posts 54 karma points
    Jan 31, 2010 @ 00:35
    Jakob
    0

    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

  • Jakob 38 posts 54 karma points
    Jan 31, 2010 @ 04:35
    Jakob
    0

    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.

     

  • Jakob 38 posts 54 karma points
    Jan 31, 2010 @ 14:34
    Jakob
    0

    jeg poster lige stacktrace

     

    [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

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jan 31, 2010 @ 15:42
    Morten Bock
    0

    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

    <add key="umbracoReservedPaths" value="/umbraco/,/yourmvcapphere/" />

    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? 

  • Jakob 38 posts 54 karma points
    Jan 31, 2010 @ 15:59
    Jakob
    0

    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:

    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>
  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jan 31, 2010 @ 16:19
    Peter Dijksterhuis
    0

    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

  • Jakob 38 posts 54 karma points
    Jan 31, 2010 @ 16:38
    Jakob
    0

    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 :)

  • Jakob 38 posts 54 karma points
    Jan 31, 2010 @ 16:42
    Jakob
    0

    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>

  • Jakob 38 posts 54 karma points
    Jan 31, 2010 @ 17:40
    Jakob
    0

    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?

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jan 31, 2010 @ 18:50
    Peter Dijksterhuis
    0

    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

  • Jakob 38 posts 54 karma points
    Jan 31, 2010 @ 18:58
    Jakob
    0

    Yeah, I think I mistoke you for Dirk. Shame on me ;) No prob. Valid input anyway ;)

  • Scott McCown 15 posts 37 karma points
    Jul 07, 2011 @ 18:20
    Scott McCown
    1

    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).

  • Amey 5 posts 76 karma points
    Mar 22, 2016 @ 06:54
    Amey
    0

    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.

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Jul 07, 2011 @ 23:35
    Michael Latouche
    0

    Hey Scott,

    I'd be very interested to get the details about this :-)

    Cheers,

    Michael.

  • wham 2 posts 22 karma points
    Jul 21, 2011 @ 00:24
    wham
    0

    Scott,

    +1

    Yes, people are still looking for answers to this. I was thinking to do the same thing. Any help is greatly appreciated.

     

     

  • Scott McCown 15 posts 37 karma points
    Jul 24, 2011 @ 08:30
    Scott McCown
    0

    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.

  • Valentin Zberea 1 post 21 karma points
    Aug 24, 2011 @ 10:20
    Valentin Zberea
    0

    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.

  • Scott McCown 15 posts 37 karma points
    Aug 31, 2011 @ 16:55
    Scott McCown
    0

    @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.

  • Doug Clark 30 posts 52 karma points
    Jul 30, 2012 @ 03:10
    Doug Clark
    0

    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? 

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Jul 30, 2012 @ 09:55
    Sebastiaan Janssen
    0

    @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

  • ajexpress 4 posts 24 karma points
    Feb 03, 2014 @ 17:23
    ajexpress
    0

    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.


     

Please Sign in or register to post replies

Write your reply to:

Draft