Advice on ASP.NET MVC project structure? [closed] - asp.net-mvc

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am a computer science student and while I have worked with MVC before, I have never built a project from scratch. The project is for a photography course, where the teacher will be able to upload featured photographs. The students must log in to be able to see the pictures and the assignments.
I would like for the students to log in at www.mysite.com, and the teacher at admin.mysite.com, so we have 2 different websites in one solution.
As of know my solution projects are:
DataLayer
BusinessLogicLayer
AdminWebsite
Website
Note: Gearhost is going to be my host.
Now, how will I host the AdminWebsite and the Website on two different domains, while both of them "feed" from the same BusinessLogic and DataLayer?
Should I instead make two different projects that work on the same database? Is is even possible?
I have made my research and read a bit about Areas, but I haven't been able to find a good tutorial, is it a best practice to use Areas instead, if so, can you provide me with a link to a good tutorial, or a simple example?
Thanks for reading!

It is common practice for simple sites and implementation to just use one project for the public, member and admin sites.
You should be able to section each area depending on user permissions so there is no need to create two separate websites.
I would suggest the following resources for best practices and examples.
Nerd Dinner (code is hosted here)
More best practices
And the best place to start MVC pages at asp.net
There is also a ton of questions and community wiki entries on Stackoverflow about best practices and website layouts.
Hopes this helps

The answer is really depends. Depends of the scale of your project. You can have it all in one project (main MVC one) of you can split it further. The canonic form for this projects is something like that:
project.WEB
project.Common (here belongs common functionality between projects, so helpers, utilities, even some extension methods belong there)
project.Model (Data entities)
project.BL //(Business Logic)
project.DAL //(Data Access Layer or Persistence)
project.Tests
*note the "project" is your namespace root. How ho handle namespace naming you can check it there: namespace naming conventions
And the you can split it further and further. However I would suggest that you do not exaggerate with splitting it any further. When you will have to do it you will know (one project grow too much, there are logic separations ...). You try to follow the principle YAGNI.
And one more thing. If you want to be there "by the book" check it out DDD - Domain Driven Desing: http://msdn.microsoft.com/en-us/magazine/dd419654.aspx.

Related

Is there any standard approach for defining projects in an ASP.NET MVC solution? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
How should I logically define an ASP.NET MVC solution? Into how many projects must I divide my solution? Is there a standard approach for this? Like for example, a model class library, an MVC web application (comprising controllers & views), a unit test project, a repository project etc... What are the different types of project one can come up with?
The answer is really depends. Depends of the scale of your project. You can have it all in one project (main MVC one) of you can split it further. The canonic form for this projects is something like that:
project.WEB
project.Common (here belongs common functionality between projects, so helpers, utilities, even some extension methods belong there)
project.Model (Data entities)
project.BL //(Business Logic)
project.DAL //(Data Access Layer or Persistence)
project.Tests
*note the "project" is your namespace root. How ho handle namespace naming you can check it there: namespace naming conventions
And the you can split it further and further. However I would suggest that you do not exaggerate with splitting it any further. When you will have to do it you will know (one project grow too much, there are logic separations ...). You try to follow the principle YAGNI.
And one more thing. If you want to be there "by the book" check it out DDD - Domain Driven Desing: http://msdn.microsoft.com/en-us/magazine/dd419654.aspx.
This is a very broad question, but i will give you an example of what I did on my previous project. Firstly, it will depend on the complexities of the overall application, and the developers personal preference. A simple app could very well fit inside a single MVC 4 application.
Web Project - for the views using MVC4
Application - for business logic)
Data - for repositories and webservice methods)
Domain - for the objects used in the app
Utilities - for common functionality that needs to be used in more than one project
The example above fitted the project very nicely allowed me to separate all the concerns making it more maintainable.

Frameworks with automatic admin interface and login [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I like to experiment with different languages to keep my interest alive when working on small side projects away from my day job.
I'm finding it increasingly difficult to steer away from Django and Ruby on Rails because of a couple of features they come packed with (or that are mostly default and easily integrated): authentication and automatic admin interface. Django comes with both, with Rails you just have to add ActiveAdmin as a gem and you're ready to go.
When I try to experiment with different frameworks and languages (Noir for Clojure, Express for Node), most of the times I find interesting languages I'd love to work with but whose "web framework" idea is just some convenience method for routing and parsing URLs and requests, leaving you alone with all the common and annoying parts of web development, like form validation, user authentication and profiling, having a working admin interface and so on, all things that Django and RoR provide to you for free.
What other languages and frameworks have such commodities? I'm aware of some PHP frameworks like Symfony, but I really have used PHP for too long in pas years and I'm pretty fed of it. Thanks.
Stick with RoR in my opinion. It's still a young yet powerful framework. It's well maintained and quickly plugged whenever a security risk becomes known.
It doesn't really matter what kind of MVC framework you use since it all comes down to the programmer. Ruby on Rails cuts out the painful part of programming (IMO) and allows you to do the enjoyable parts. Requiring knowledge of SQL is very minimal within Rails unless you're doing complicated scoping.
If I kept searching around for different languages to explore after I found one that suited all of my needs and then some, I would never get anything done. Moving from PHP/CakePHP to Rails is definitely an upgrade in my opinion, but at this point, you're better off committing to one language (Python/Django or Ruby/Rails).
I would stick with Django. Having worked in everything from classic ASP, ASP.NET, ASP.NET MVC, Java, PHP and Rails, I can state, unequivocally that Django is hands-down the easiest to work with, most profitable framework I've ever used.
Rails does have some pretty controllers, but it pales in comparison when you get down to functionality. Sure, Rails has lots of plugins, but Django has nearly everything you need under one roof. Django-admin alone is a friggin' gold mine. I work full-time as a Technical Architect, but also own my own business. Switching from Rails to Django in 2008 was the single best thing I ever did for my business.
If you want something flexible, modular, easy-to-extend and incredibly well documented - Django is your ticket. You also see far, far fewer of these lovely posts with Django.

MVC site search functionality [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
i need a simple site search functionality for my mvc app. some of the pages are static and some dynamic (like news articles that are entered in cms). I would like the search to handle both. is this product any good? http://www.sitesearchasp.net any other?
#stephbu - Thank you for the mention.
If you choose to use arachnode.net, you have the choice of either Lucene.NET or SQL Full-text Indexing.
There are some 'head-scratchers' with Lucene.NET, especially when establishing concurrent read/write/search scenarios, but as a static reflection of content it works very well.
If you want something that is free, and turn-key, try Solr(.Net) or Microsoft Search Server.
http://www.microsoft.com/enterprisesearch/en/us/search-server-express.aspx (this was free last I looked at it...)
Thanks!
Mike
Resist buying anything if you can - there are many free .NET based search engines out there. Favourite of choice would be Lucene.net, decent tutorial here:
Lucene Tutorial
It's fairly simple to setup, you control what data is indexed through the Lucene API. There are open-source spidering extensions like Arachnode out there if you need crawling. Its mighty powerful for indexing catalogues etc.
Guess it depends how important search is for your business relative to the cost of owning a search engine. Buying one will probably give you turn-key functionality, but no doubt will run to the same cost of integration if you want more advanced features.
You could also consider using Solr, which is a search engine Web service that sits on top of Lucene, and provides extra features such as hit-highlighting and faceted searching. .NET integration is available through the SolrNet library. Both Solr and SolrNet are free.
By using SolrNet you can easily index your database content. I use NHibernate for database access, and SolrNet also has NHibernate integration, so documents get automatically re-indexed when the content changes. You could easily set up a similar arrangement for your database access method of choice.
For the static pages, you could either submit the HTML programmatically or use a Web crawler (see this question for some suggestions). I haven't needed to do this, so I can't make any recommendations on which tool to use.

How do I index and make available reusable code? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have many small files containing code fragments, pseudo-code algorithms, classes, templates, SQL-samples, etc., and I obviously cannot put all these into libraries. I need a practical method to index all of them, and to be able to make this index available to others.
What must such an index contain to
make searching easiest?
Are there any such repositories
available on the web? (So I can test
the techniques they use.)
Are there any applications already
written that implement this that I
can have a look at?
Possible duplicate: https://stackoverflow.com/q/90300/15161
If you're working with .NET / Visual Studio, you could look at adding them as code snippets
Code Keep is a pretty good online repo for CodeSnippets and has plugins for VS2008
What we've done at work is created a common account for the dev to use, so everyone submits to codekeep under a common login and then can retrieve everyone elses snippets.
Also it might be worth your while creating a developer wiki on your dev network. Somewhere that the old hands can leave documentation on your regularly used patterns & snippets and new team members can check for help. We use TRAC in house as an all in one WIKI / Issue Management / SVN Integration and it does the job nicely
Another similar result from searching StackOverflow: Best Application For Storing Code Snippets
You might want to try refactormycode.com or set up your own wiki for it. A wiki actually sounds like a good application here.
I find the only way to manage source code is in the source control repository. This includes templates and pseudo code algorithms.
How it's different from the rest of your code ?
I'm familiar with cvs that can be hosted for example here (setting up cvs server is not to complex task either) you can search the repository using cvsearch and browse it using cvs web client.
I'm not saying cvs is a best option just another one that fulfill all your need.
Code snippets is a not a good option, IMHO.
You can do a full-text index of your hard drive using a tool like Copernic, Windows Live Search, or Google Desktop. Then whenever you want a code snippet that does a specific thing, just search for the relevant keywords and there it goes.

MVC or event-driven component-oriented web frameworks? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
This question intends to be technology-agnostic. Which kind of web framework do you prefer, and when: Pure MVC or event-driven component-oriented?
Just to make the point in "technology-agnosticism", here I name a few MVC vs. component web frameworks, in diverse technologies / languages:
Struts vs. Java Server Faces / Tapestry
The new ASP.NET MVC vs. "classic" ASP.NET
Cake PHP vs. PRADO
I'm a php dev by day; however, I strongly prefer Wicket and/or Lift, especially the latter. The problem with Prado seems to be that the controller is tied to the page, rather than the logical controls on the page, otherwise, it still seems better than most other options in PHP land. I think all boils down to reusability, unless you have components that are backed by controllers, you can't separate the display all that well from the backing control logic.
MVC as implmented by all these 'MVC' frameworks seems to suck, you get a logical page with a tonne of controls and you have to handle all those on page controllers, wow, thanks, now I have MVC / n, where n is the number of controls. Most 'MVC' systems that I've seen so far, have been a mish-mash of brain-dead tag libraries, contorting request response into a single controller that has to be aware of everything on the page.
xhtml templates with js, and css wonderfully separated. Along with a few classes backing those components, and all of a sudden you're not busy wondering how complex pages are going to work, or if you want to take piece x, and drop it somewhere else.
Right now, the 'new hotness' trend is towards the MVC approach. I personally prefer the conventions of MVC frameworks, as a lot of the scut work that takes up valuable development time is done away with. That being said, the constraints tend to be fairly rigid, and a more traditional component-based approach might be needed in certain situations. All in all, it's a right tool for the job sort of choice.
The technology used is usually not matter of choice and especially in a big company you don't have many options.
If I were able to choose a technology, in Java I would pick Wicket. I have been using Spring MVC and it is good, but Wicket has a neat features that Spring MVC has not: server-side state management and encapsulation, rich component model, no unnecessary XML mapping files - just pure Java and HTML.
I'm primarily an ASP.Net developer, but I find MVC is a better way of creating functionally complex websites (typically Line-of-Business type sites) since it allows for better separation of business logic and rules from the markup used to display data to the end-user.
For quick and dirty sites (typically with a direct connection to the database) or richer interfaces, the "event-driven component-oriented" model is more effective.
Personally I would say MVC is the way to go for web sites. You have a lot more control over the HTML and CSS and at the same time the controller pattern works very well with HTTP. Event driven web programming is great for small sites or for people who are not that clued up with HTML and CSS and more low-level concepts.
I loosely follow these guidelines:
Web Forms/SQLDataSource- Quick and dirty app for internal use to show reporting or some other such data.
MVC- Simple to complex business logic for a core product.
MVC/REST Web Services/jQuery- HTML/Whatever type of client RIA's (when user experience reigns supreme).
Flash/Flex RIA- Useful when an extremely rich client is needed (think multimedia manipulation here).
There are a lot of gaps in this list of course but that just represents how complicated a question it is.

Resources