I know to start using areas, you have to establish parent/child relationships. I have a couple areas setup and their controllers are hitting just fine, the problem is some Views are not found. I'm trying to gain an understanding of what's happening to my controllers that are not happening with my Views.
I'm very familiar with MSDN's link but I'm still having a disconnect:
http://msdn.microsoft.com/en-us/library/ee307987(VS.100).aspx
My guess is that maybe it is something to do with the routes. Check to make sure you a registering all of your routes correctly (There's a couple extra things you need to account for when you are using Areas).
Phil Haack wrote a great blog entry on Areas, which may help with your problem.
Edit: Download the ASP.NET MVC source and step through the code to see where it is breaking. This should let you know exactly where the issue is.
Total user error, I ended up creating a new area and forgot to uncomment the child area in the project code behind. Sorry for the mislead! Make sure to uncomment your parent and children area projects!
Related
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?}");
I have gone through many of the MVC tutorials and now I want to create a prototype mvc app of an existing database.
I have installed the MVCScaffolding package and I want to use it with an existing database. Has anyone found steps to go about doing this? I have looked but have been unable to figure out how to get it to work.
I want to connect to a sql server database and have the model created from it. Then scaffold out the views and controller.
Is there something I am not understanding here? Is this how MVC Scaffolding works?
this might be a little complex to work with at first, but then you will discover the beauty of it. Check this tutorial out, it helped me a lot when I started Asp.Net MVC 3, also Asp.Net site helped me a lot. Scaffolding is nothing more than a bunch of templates to make your life easier, nothing more. You could also check ScottGu's Blog about this same topic.
Good luck!
Does anyone have any experience creating a skin engine for asp.net MVC? I know the suggested approach is to use flexible markup with CSS, but I would like the ability for a new view to be dropped in, and the application use that one instead of the default one.
Basically, I want to know how to tell the framework (at run time) to look into a specific folder for the views/content, and if the item isn't there to check the default locations.
I started to look into how the Oxite blog engine does it, but it seems like that might be a bit much for what I need (I am still looking through it, so I could be wrong.) Any help is appreciated.
You need to change the ViewEngine a little bit.
See this post http://bartreyserhove.blogspot.com/2009/02/building-multi-tenant-applications-with_22.html
It can be done for partials and masterpage also.
I am really missing heavily the ability to test Views independently of controllers. The way RSpec does it.
What I want to do is to perform assertions on the rendered view (where no controller is involved!). In order to do so I should provide required Model, ViewData and maybe some details from HttpContextBase (when will we get rid of HttpContext!).
So far I have not found anything that allows doing it. Also it might heavily depend on the ViewEngine being used.
List of things that views might contain are:
Partial views (may be nested deeply).
Master pages (or similar in other view engines).
Html helpers generating links and other elements.
Generally almost anything in a range of common sense :) .
Also please note that I am not talking about client-side testing and thus Selenium is just not related to it at all. It is just plain .NET testing.
So are there any options to actually do the testing of views?
Thanks,
Dmitriy.
The main issue with testing full views is that the asp.net view engine calls Response.Write in the supplied context / and not on the supplied writer.
The above is not the case for testing partial views, so for those you can use this solution:
http://www.brightmix.com/blog/renderpartial-to-string-in-asp-net-mvc/
There are other view engines that do allow you to test the view i.e. Spark.
ps. the concept in asp.net mvc is that you should be able to test the view by using the ViewEngine, but as I understand the asp.net mvc team didn't work around the existing asp.net engine restrictions to be able to do so for their view engine.
You may want to check out the UI Test Helpers that Eric Hexter and the guys with MVCContrib are working on. I haven't had a chance to look at it in depth, but it may help you. I found this link that shows some of the syntax: http://codepaste.net/cw8ie4
I would be interested to know what you find out as I will be doing this pretty soon also.
Interested to know if you find anything for .Net that does this. Our current app is WPF, but we are stuck with trusting Cucumber to touch our Views in all our Features... so yeah, that sucks. Hope you find something and update us.
I've done a large study into using MVC and thanks to the people here a lot of the issues revolving around it have been cleared up for me.
The problems I'm having now revolve around the sheer size of our application and how it would be organised within the project itself. For example, we have url's such as http://mylocalapp/folder/nestedfolder/subfolder/theapp. The reason we do this is because the application quite literally is that large. We need that kind of folder structure because otherwise the application would be unmanageable.
Phil Haack covers the registering of routes for nested folders in one of his blog posts which is very useful indeed, but our application has sub-applications and sub-applications within that. It couldn't be simplified any further.
What steps need to be taken to manage such a large application which spans a large amount of folders and has folders up to seven levels deep, as well as having about 15 databases? Is MVC really the answer for an application of this size?
Is another option simply to apply lots of URL routing and map route areas for all the separate sub-folders?
If you don't need to have everything inside of one application, why not create an MVC application in each folder?
I have a similar situation and what we did was instead of making a "fat" controller, we make them "skinny". Ian Cooper has an excellent write-up here.
So what we did is we broke down the "sub-applications" to be its own application. I think this is what the previous posters trying to convey as well.
As per a comment "Are you refering to "Areas"?" was the answer eventually.