mvc application at mvc application - asp.net-mvc-3

I wrote a simple web application on ASP.NET MVC3 (for example, app1). And I now want to write a simple CMS for it (for example, app2).
How can I access to folder app1/Content/ from app2, if app2 is an independed application?
In the future I want to copy app2 to one of the folders of app1 (for example, app2 path will be C:/app1/app2/)
Is this approach correct for building sites in ASP.NET MVC3? If not, please, recomend a better approach!
Sorry for my English.

You should use Area not a different project for simple usages. you can find more here

First of all, yes, it's not a very good design choice.
If you need some common stuff between the 2 applications, you can use several approaches, the simpliest that comes to my mind is to define in each application a variable in app settings (inside the web.config) pointing to a folder or URL containing the common stuff and use that.
Same thing if you need to use the same DB from more applications: just use the same connection string.
If you really need to make the 2 apps work together for some reasons, you should make one single app and a viable solution could be to split it using Areas.

Related

Which is better? Single-page vs multi-page simple Sinatra service

I'm developing a small data-crunching / visualization app in Sinatra, and am split between two options.
The functionality is that you:
Upload a file to the app.
See a nice visualization of its contents.
Maybe start over with a new file.
So my choices are:
Letting both views (upload and results) be managed by the same template, thus creating a single-page app.
Splitting uploads and the visualization between two pages. You upload a file to '/', then are redirected to that file's URL which displays the results.
Which one is better? The advantage of the first is that I can manage it all within the same page, by passing some local vars between the two views.
On the other hand, the second seems like the more RESTful option - because each uploaded file gets its own URL and can be treated as a resource (more fine-grained control).
So, if you want to provide a RESTful API as well along with the web application, it is good idea to have tow different routes.
If you are planning to have just a web UI, it depends on how much control you want to give to the end-user.
Nothing is wrong with either of the approach. It depends on how much ease you can provide.

3 MVC projects in 1 Solution

I have to build 3 MVC web applications using Entity Framework (www.company1.com www.company2.com www.company3.com). The websites will all access the same sql server database, but will be slightly different in their own way (appearance, data etc). More than likely all three MVC applications will be hosted on the same server, but binded to different domain names.
Currently in Visual Studio, I have the following structure to my solution
Domain Classes
Data Layer
Services
Repositories
MVC App 1
MVC App 2
MVC App 3
I would have preferred to have used Area's, but I can't because each site has to be assigned it's own different domain name. I guess I am just seeking assurances that architecting my solution this way won't cause any difficulties for me when the applications are published. I am slightly paranoid about the sites sharing the dbContext or something, however, I know that many sound silly.
It would be great if anyone could advice me if this all looks ok, or maybe there is a better way to do what I am asking.
Thanks as ever.
I've done the same thing for the same reason. I have a CMS that must reside at a different host-name. It works fine.
The trick is finding ways of sharing code across the MVC apps. To avoid circular dependencies and such, I created one more MVC app to hold things such as my controller that serves up image files, HTML Helpers that can be re-used, etc.
As long as you have a good way of validating and differentiating the sites in the Datalayer, than you will not have to worry. How are you validating this?
I also would always put simulair code and pages in a main project so you do not copy parts or even whole pages for different sites. (My guess is that you already did so)

asp.net mvc - nested site deployment

How do I enforce an asp.net mvc application to point to the subfolder instead of root folder.
Lets say I have website called: http://mywebsite
I have got totally different asp.net mvc applications called UserApp and CustomerApp. There is no common thing between them. Now, I want to deploy the application like:
http://mywebsite/UserApp/SomeController/SomeAction
http://mywebsite/CustomerApp/SomeController/SomeAction
I deployed the application above ways. But, after deployment, only home page works. Any other nested controller/action still points to root path instead of specific path.
You probably need to set both subfolders as applications in IIS.
The answer from Slaks is not enough, as default MVC routing is "/controller/action" from the web root.
You could use the IIS routing module to rewrite paths so that http://yourWebSite/UserApp/SomeController/SomeAction is rewrited to http://yourWebSite:8080/SomeController/SomeAction and setup 2 websites on different ports internally.
Or you could modify mvc route mapping. It could work, ... or not. Search for "MapRoute" in MSDN.
Or you could create 2 websites with 2 different hosts.
This is not unusual for 2 unrelated websites :=)

.NET MVC Localization and Globalization

I continue with a MVC Web App, and now I'm between the concepts of DRY (dont repeat yourself) and decoupling (be independent).
I divided my big Web Site in diferent projects within a Solution, and as you may already know in MVC the Validations are done in the Model or Service Layer, that in my case its in a diferent project than the one holding the App_GLobalResources, and here is the thing:
How can i access the GLobalResources from a different project, so I can access the strings to set the errors on the model in the service layer?
So far i created a new project like stand-alone resx files and complied them to set the reference to the DLL but it doesnt work, because the main resx files are internals or privates.
I tried one of those custom tools to make resx files public (cross assembly avaiblable) but it didn't work either, because it throws:
No matching culture found
The best aproach so far is to create a resx file just for the Model Project and it works good, but I'm repeating the same strings twice, one for the Views (to set the jQuery string validation errors on client side) and another one for the Model Validations (server side), these give me the benefit of decoupling, but what happen with DRY in this case?
Any advise or tips?
Well i have decided to follow two separetes resx (for strings), one for the Views & Controllers and another for the Model->Service layer, Im using a service layer for validation, so i isolate that layer, in that way i can reuse the layer "Service" or (BLL), in a way that i can reuse it later in somthing like a WPF app, with out any reference to the resx of the Views or Controller. SO decoupling won here ... =)

Do you know any examples of a PAC design pattern?

Can anyone point to any websites or web applications that are using the Presentation-Abstraction-Control design pattern rather than MVC? Desktop applications are easy to find like this (e.g.; GIMP) but I'm looking for something on the web.
There are more sites using PAC than, I think, people realize. For example, drupal uses the PAC pattern and there are a lot of sites (and a lot of big sites) built with drupal. Many people confuse MVC and PAC. Larry Garfield does a good job explaining the difference and how drupal uses PAC.
In my research on this topic I found more than one open source app/framework that called themselves a MVC architecture when they more accurately fit the PAC pattern. Specifically in the way the model/abstraction, presentation/view, and controller interacted with each other.
I suspect most sites written using what is called MVC are in fact using a version of PAC but with a single triad. MVC specifically requires the view to be able to communicate with the model directly without going via the controller. I think many web developers would expect this to always go via the controller regardless of the direction of communication.
You have difficulty to get Web application that use PAC because PAC inheritance pattern work well on custom component and custon dialog box that is not really present in the web.
Many framwework use PAC that let you override the presentation, abstraction or control but when used in the web, mostly transform to MVC for it's simplicity (for example, you do not need to have a new level of PAC to change the appearance of a grid... you can use CSS file).
This is the best answer that I can give you.
The only example I've seen is in Pattern-Oriented Software Architecture Volume 1: A System Of Patterns.
Drupal is a PAC based web framework in written in PHP. :)

Resources