c# - A Solution for Maintaining Views in Single-Project Areas -


I have tried this in only one project area, so if anyone resolves it in multi-project areas please let us know .

Field support was added to MVC2. Although the views of your controllers should be in your main view folder. I will allow the solutions present here to keep specific scenes of your area in each area. If your project is like the following, then with blog being a region.

  + area> lt; - Folder + Blog & lt; - Folder + view & lt; - Folder + Shared & lt; - - Folder Index.aspx Create.aspx Edit.aspx + Content + Controllers ... ViewEngine.cs  

Add this code to the Application_Start method in Global.asax.cs. This will clear your current viewing engines and instead will use our new ViewEngine.

  // View Area Aware View Engine Engine. Cleaner (); ViewEngines.Engines.Add (see new areaisin ());  

Then create a file named ViewEngine.cs and add code below.

  using the system; Using System.Collections.Generic; Using System.Globalization; Using System.Linq; Using System.Web.Mvc; Namespace MinesaceSpace {Public classroom areaWEINEN: WebFormWeinGen {public sectorWINENGIN} {//} see {//} {//} {name of controller / master page location Master position preferences = new [] {"~ / views / { 1} / {0} .master "," ~ / scene / share / {0} .master "}; // View location lock parameters = new [] {"~ / view / {1} / {0} .aspx", "~ / view / {1} / {0} .ascx", "~ / view / share / {0} .aspx "," ~ / views / shared / {0} .ascx "," ~ / fields / {1} / view / {0} .aspx "," ~ / regions / {1} / view / {0} .ascx "," ~ / field / {1} / view / share / {0} .aspx "," ~ / region / {1} / view / share / {0} .ascx "}; / / Partial View Locations Partial Views Space Requirements = ViewFormat; } Protected Override IView CreatePartialView (Controller Content Contributor Contintbox, String Partial Path) {Return new webformview (partial path, blank); } Secure Override IView CreateView (Controller Contbox Controller Contintbox, String Frontend, String Masterpiece) {Return new webformview (frontend, masterpath); This is a possible solution that will find and use the ideas created in your area.  

Allow me to keep in mind in the specified area Is anyone else having a different, better, advanced solution?

Thank you

I'm sorry to tell you this, but something Remember I'm currently working with box with ASP.NET MVC 2 RC in your scenario.

I think you have all the register paths and the right web in the view folder of your area. Is the config file?

Maybe, there is a look especially about creating areas.

HTH,
Charles

EDIT: OK, you are not happy about putting additional new {domain = "blog"}, meaningless - Fair enough, I'll accept your own mouthpiece ... but what are you going to do?

What happens when you have two controllers with the same name? One controller with one name from one of its original project and one in one area or in two different areas? How is this finding the right view?

In addition, I see a problem with your ViewLocationFormats . All field view locations have no reference to their area ... such as ~ / Areas / {1} / views / {0} .ascx - which area to know this?

If you are suggesting that I throw the idea of ​​all the different areas and all the area folder under their controller name and then view and view / share - I would highly recommend this against ... this'

So where do you go from? It actually leaves you to specify the area while building the pathway, it really blurs the fact that although it is an eye for specifying the area, there is actually no other way.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -