I'm just learning this stuff myself, in fact only moments ago did I get something very basic like this finally working myself, but found that if you have a controller named "HelloWorldController" that inherits from RenderMvcController, then you can't surf to /HelloWorld/ as you might expect from a traditional MVC application. Instead, there appear to be two ways you can get your controller and action to run:
The first way is that you have to create a "HelloWorld" document type in your site (with exact alias "HelloWorld"). Then you can create as many new pages in your site as you want using this document type, and give them whatever names and URLs you want. So for example if you create a new HelloWorld page called "Test", then you can get the Index action on your HelloWorldController to run if you surf to /test/.
The second way adds on top of this by allowing you to create additional action methods in your HelloWorldController. You can name these new methods whatever you want, and then you will also create some templates in your site using the exact same aliases as these method names. So if we build on the previous example, you could create a new action method in your HelloWorldController called "Greet()", and then also create a template called "Greet". Now if you change the /test/ page to use this new Greet template, you would find when you surf to /test/ that the Greet action method will execute. Any other template names that aren't matched will fall back to the Index action method.
Basically it took me a lot of trial and error and surfing the web and people's blogs and reading the official documenation dozens of times over and over again to finally figure this out. The official documentation didn't quite click with me at first in terms of how to actually get things working from start to finish, but now that I have figured things out enought to get a basic example actually running, the Custom controllers (Hijacking Umbraco Routes) documentation page makes a bit more sense to me now, so I'll recommend you do the same if what I've written here has helped at all.
P. S., when "hijacking" routes the way I discussed, you won't need to add anything to the ReservedPaths key. That would be for a totally different way of doing things which is if you want a completely custom routing, not for "hijacking" i.e., when inheriting from RenderMvcController...
Extending Umbraco with your own Controllers - Not Found Error
Umbraco 6.1.1 MVC Visual Studio 2012
Have managed to finally build an Umbraco Site from within Visual Studio, thanks to a couple of great web post that describe each step. http://www.systenics.com/blog/setting-up-umbraco-6-in-visual-studio-2012-for-mvc-development/ and http://www.ben-morris.com/using-umbraco-6-to-create-an-asp-net-mvc-4-web-applicatio,
I have added my own HelloWorldController and an Index Page within a HelloWorld Views folder.
I have also added my path to the ReservedPaths key
When I try to browse to http://localhost:58855/HelloWorld/ I get the 404 page error HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
So my question is, what else do I need to do to get a simple external page to work? Is it possible?
Thanks for the help
Paul
By now i just created normal controllers outside the umbraco ones by using them in an area. So don't have tried it that way before.
My first guess would be that you have to add the path to the RoutesTable because the route is not known.
If you inherit from Surface- or RenderMmvController than Umbraco knows the routes automatically.
Hi p.kidd,
I'm just learning this stuff myself, in fact only moments ago did I get something very basic like this finally working myself, but found that if you have a controller named "HelloWorldController" that inherits from RenderMvcController, then you can't surf to /HelloWorld/ as you might expect from a traditional MVC application. Instead, there appear to be two ways you can get your controller and action to run:
The first way is that you have to create a "HelloWorld" document type in your site (with exact alias "HelloWorld"). Then you can create as many new pages in your site as you want using this document type, and give them whatever names and URLs you want. So for example if you create a new HelloWorld page called "Test", then you can get the Index action on your HelloWorldController to run if you surf to /test/.
The second way adds on top of this by allowing you to create additional action methods in your HelloWorldController. You can name these new methods whatever you want, and then you will also create some templates in your site using the exact same aliases as these method names. So if we build on the previous example, you could create a new action method in your HelloWorldController called "Greet()", and then also create a template called "Greet". Now if you change the /test/ page to use this new Greet template, you would find when you surf to /test/ that the Greet action method will execute. Any other template names that aren't matched will fall back to the Index action method.
Basically it took me a lot of trial and error and surfing the web and people's blogs and reading the official documenation dozens of times over and over again to finally figure this out. The official documentation didn't quite click with me at first in terms of how to actually get things working from start to finish, but now that I have figured things out enought to get a basic example actually running, the Custom controllers (Hijacking Umbraco Routes) documentation page makes a bit more sense to me now, so I'll recommend you do the same if what I've written here has helped at all.
Best of luck to you!
P. S., when "hijacking" routes the way I discussed, you won't need to add anything to the ReservedPaths key. That would be for a totally different way of doing things which is if you want a completely custom routing, not for "hijacking" i.e., when inheriting from RenderMvcController...
is working on a reply...