Integrate Umbraco in an MVC and not the other way round - asp.net-mvc

I have little to no experience in Umbraco, but it has been suggested to me as I have been asked to integrate a CMS system within my existing application. I have gone through some videos how to use Umbraco and done well so far. The problem is as follows. I have an existing MVC application with custom routing but both use the same database and dll. Example: www.ngomalta.com and animalguardians.ngomalta.com
Both have same interface, but with custom routing I can load some pages on a subdomain but not in the other. I would like to implement the same 'logic' using Umbraco. That is, I want both sites to have access to umbraco but they would have different content. Please note that it may be that I would have other sub domains in the future such as tomasina.ngomalta.com, and thus I would like scalability.
I have had a look on the net and other answers. However the solutions that I found are vice versa! What I mean is, that solutions given assume that you have an Umbraco site and you want to add an MVC controller. My situation is the opposite, I have the MVC and would like to add Umbraco views. Thus I want to make Umbraco compatabile with MVC and not design an MVC solution to be compatible/integrated with Umbraco.
Currently I have implemented a class that Inherits UmbracoApplication + WebBootManagerand and which overrides the Complete function. I have also tried to use my existing custom routing class (that inherits from [RouteBase]). It looks as if they work.. but the CSS styles and javascripts are not sort of routed or I don't know. They just aren't sent to the client. hence only the HTML is sent for both Umbraco page and my existing MVC views
First of all, is my idea with Umbraco possible?
If yes, can someone guide me some site that implements Umbraco in an existing (LIVE) MVC application and not the other way round? many of the tutorials that exist always start from a blank MVC application and build on that. I don't want such tutorials. I need a tutorial, that shows how an existing MVC application with already-existing-controllers that tries to integrate Umbraco.
Thanks for reading people..
!

Related

How to add second application to MVC website

Say I've got an MVC website, www.codesmurf.com for example, set up with default ASP.NET MVC routing, nothing fancy. So my BlogController can be found at www.codesmurf.com/blog, and my FAQ similarly at www.codesmurf.com/faq.
Now if I also have a small survey project, currently in a different solution, how would I achieve to access this survey at www.codesmurf.com/survey?
What changes would I have to make to my routing and/or project structure to achieve this? So the entire survey project would be at the controller level of the main website, judging by the uri.
Do I have to achieve this using Areas? Do I need to create a SurveyController on the main site to redirect internally? Do I need to host this website separately and redirect externally? Any IIS configurations? How do I make sure my old routing isn't messed up?
This seemed like an easy task in my head at first, but I really have no clue what the best way to achieve this would be, and questions keep popping up in my head the more I think about it.
Note that the survey site is also an MVC project with its own controllers etc..
I haven't had much experience with changing the MVC routes, but would like to understand what I'm doing as well, so context/explanation would be greatly appreciated.
I personally would add the survey functionality as a service reference to your current MVC project.
Add Areas/Survey to your current MVC project and then start using the code from the service reference as you build up the Survey area.
When adding areas, all you will need to do is add some more rules to your map routes.
routes.MapRoute("areaRoute", "{area:exists}/{controller=Home}/{action=Index}/{id?}");

How to add an mvc page to umbraco

I have Umbraco 7.5 and I need to know how to create normal MVC pages for adding new data to my site.
Lets say I have a Doctype "Node" in back-office. I want to let some people be able to add/edit some nodes without going through back-office. How can I do it?
I've tried to create add my view and controller (the MVC way), but apparently Umbraco hijacks all routing and my controller won't hit at all.
I've googled the matter (which is hard since I am not looking for Umbraco forms :| )and I've found this. But I prefer not to add my form as a part of other page. I mean, does it make sense to create a page in back office from type "something" and then on its template I do my add/edit form of another type? Seems strange, right?
I appreciate any ideas/ solution to this matter
You have a couple of options here. You can create a physical page for the editor to sit on, and add the editor as a SurfaceController action (basically an MVC Partial with Postback, that is still part of the Umbraco pipeline). Your form can then use the Content Service API to update the details. The advantage of this method is your code will have access to all of the Umbraco methods and templating out of the box. You could also use WebAPI controllers for the form if you want to do it all client side with JS requests.
You could also use route hijacking: https://our.umbraco.org/documentation/reference/routing/custom-controllers this allows you to have your own custom controllers for Umbraco routes, rather than using the default Umbraco ones. This is a bit more work to set up.
Finally, you can also tell Umbraco to ignore certain paths entirely, and you could run your controllers on those paths. The disadvantage here is that as the routes are being ignored by Umbraco, you don't automatically have access to all the useful Umbraco templating etc.
I've used the first method recently, and it works fine. The only caveat is that allowing users to edit nodes will fill up the version table quite quickly if a lot of users are editing a lot of nodes (every time a node is saved, a version is created). If you're going down this route, you may want to investigate something like Unversion: https://our.umbraco.org/projects/website-utilities/unversion/ which helps to keep old versions more manageable in situations like this.

Creating MVC Application That Can Easily Integrate Into Existing Applications

I have created a custom MVC Forum application. But I'm starting to think that although it works great as is, I'm going to need to get it to work within other MVC apps (In fact I have actually been asked that already).
What is the best way with an MVC app to structure/develop to make it as easy as possible to integrate into an existing MVC application?
Areas? Develop within a sub folder from the start? Or is it just you have to work through and merge configs/controller clashes if necessary.
No need to Config or ... . you only need to create ability in your Logon Model and it's Controllers. A complete example is in Asp.net MVC 4 which Microsoft has added more libraries for authenticate from other sites/profiles. Also the model has changed a few in properties. see this technology or download MVC 4 framework to learn it. it's easy.

MVC 3 Domain Routing

I would like to know if the following is possible. I have a website called www.myweb.com. This website could be a directory of say football teams. The list of teams could be found here
www.myweb.com/home/teamlist
On selecting a team one would be take to
www.myweb.com/teams/teama or
www.myweb.com/teams/teamb etc
the content under the teams area would be related to them e.g.
www.myweb.com/teams/teama/fixtures
www.myweb.com/teams/teama/news
i have the above working but would like to know if it is even remotely possible to have a separate website for each team which still uses the current models, views and controllers e.g.
www.teama.com
would go to display the data from
www.myweb.com/teams/teama
where 'teams' is the controller and 'teama' is a parameter for a 'details' action. Also doing
www.teama.com/fixtures
www.teama.com/news
would display the same stuff as
www.myweb.com/teams/teama/fixtures
www.myweb.com/teams/teama/news
many thanks and hope i have worded it ok.
Rudy
I would consider using IIS URL Rewriting in that case.
Have a look at MVC Domain Routing, I'm still researching it myself as I have a similar required as yourself but I think that should do what you need.
The following links might be handy:
ASP.Net MVC Domain Routing
Bolt on multi-tenancy in ASP.Net MVC Part I (link to Part II is on the page)

ASP.NET cms and display template - 2 projects or just 1?

This is a ASP.NET MVC beginner question (I'm in phase of developing NerdDinner)... I have assignment to create ASP.NET MVC cms (with its own design) and portal (also with its own design) that will display data that's being handled by CMS. I was wondering if I will have to make two individual projects in Visual Studio or I will have to use one project and place portal section in specific folder.
I know that my question is a bit premature (according to fact that I still haven't finished tutorial) but I'm bit impatient :)
On server (commercial hosting) I would use only one hosting account... this thing with URL routing is a bit confusing to me, CMS is practically also optimized for SEO.
I would like to the structure of URL to be:
---- PORTAL ----
www.domain.com
www.domain.com/Menu1/Submenu1
www.domain.com/Menu2/Submenu1/SubSubmenu1...
etc.
---- CMS ----
www.domain.com/CMS
www.domain.com/CMS/Whatever
Thanks,
Ile
It all depends on the functionality of the portal and the MVC cms.
For starters I would have a separate solution for the Model/Data Access that way you can have as many MVC projects without duplicating your data access.
From your desired url structure I would probably have the CMS as a separate controller and sub folder. Alternatively if your using MVC 2 you could look at the areas support which will probably give you a little more flexibility.
If you want the solution to be a bit more complex/flexible you have a number of options:
If both the portal and MVC cms are going to have he same functionality and page layout you have two master pages and determine which mater page to show when returning the view. You would specify this in the routing so multiple routes would point to different controllers.
If the layout/functionality differs slightly but one controller can still manage both you could have a separate controller project and two mvc projects which only contains the views, javascript and images so both mvc solutions look at your controller solution. With this option you would probable end up setting up two websites on your domain one under the root and the other under the CMS folder (in your MVC app you will prob need to block routes to /CMS so it will be processed by your CMS app).
Finally if both differ hugely have two separate projects but keep your common data access project, as above you may need to set up two sites on your hosting package.

Resources