ASP.Net MVC guidelines

Fuma

Executive Member
Joined
Jul 9, 2007
Messages
5,366
Reaction score
346
Location
Pretoria
So I've been procrastinating to do MVC for years now, but I managed to go through some tutorial, videos and I'm busy reading Manning's ASP.Net MVC 4 in Action book and it is a good read.

I understand controllers (and actions) and views. I can actually write a decent small system with it and and the whole scaffolding makes everything quicker. In fact I'm busy developing a small system (which might grow in a long run) fro my company's one department.

I understand you can put your POCOs in a your model folder if it is not such a big system, but from my experience in my company, the user requirements grow every day. So I develop as I go along.

Any tips as to developing a well structured project? This is noobish question, but I have a lot of systems that I developed in Web Forms that I intend cleaning up and moving them to MVC in my spare time.

Read a lot on SO and youtube videos and everyone seems to have their own way of doing things. I kinds like this structure somewhat.

MVCDemo.Common ==>Class library
MVCDemo.Core ==>Class library
MVCDemo.DAL==>Class library
MVCDemo.Web ==>web project with my controllers, view, models, css, js, etc

Any suggestion or direction will be appreciated. Tx


Edit: Should I use EF or should I just user Micro ORM (e.g. Dapper)?
Been using Dapper (thanks to semphore) for all my WebForms projects and I'm happy with it.
 
Last edited:
Been developing small applications with MVC as well now for close to 1 year.

I've noticed that nobody has a clear cut way of structuring their applications, just a few basics (which you've already shown)

UI
BLL
DAL (EF and CRUD)

The controllers are mainly just a middle man for my UI, most of my logic is located in my BLL.

There is one thing I do try to adhere to at all times, and this is also true for all my other projects:

The S.O.L.I.D principles.
I always try to follow those rules to the letter, the amount of flexibility and porting you can achieve with these principles is fantastic. An example would be how my BLL never knows of the ViewBags or the Entities / CRUD from my EF. I use IoC (Invertion of control) containers to get data to my BLL. With this its easy to keep my BLL in its own dll, which allows me to keep the same version of it between all my projects, I can even port them to java with little effort.

In summery I guess there isnt a "perfect" way, but only some guide lines.
 
PS. MVC 5 basic templates for applications now contains Single Page Applications, and support for Twitter Bootstrap (excellent!)

The security on it has also been improved dramatically, making it great to handle authentication (but it takes a while to understand whats really going on there behind the hood :o )
 
Just developed a simple application and tried to deploy it to IIS7.5 win2008 R2 and no success always getting 403/404 errors

- Installed MVC 4 on my server
- I made sure my global.asax registers the routes
- My web config has:
Code:
<modules runAllManagedModulesForAllRequests="true"></modules>
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
- Also used the "Add Deployable Dependencies"
- Played around with the Application Pool (ASP.Net v4.0, ASP.Net v4.0 Classic, DefaultAppPool, Classic .Net AppPool)
If I put an an aspx or html page in the directory, I can reach it. The server does run my WebForms fine.

I can run the application on my local machine.

Any suggestion I should look at?

Edit: After try this and that, I had to follow this
Added this on my Global.asax file
Code:
            routes.MapRoute(
              "Root",
              "",
              new { controller = "Home", action = "Index", id = "" }
            );
Been struggling with this since yesterday. Eish
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X