Common questions

FacebookTwitter

Dependency Injection in ASP.NET MVC NerdDinner App using Unity 2.0 - Shiju Varghese's Blog

In my previous post Dependency Injection in ASP.NET MVC NerdDinner App using Ninject , we did dependency injection in NerdDinner application using Ninject. In this post, I demonstrate how to apply Dependency Injection in ASP.NET MVC NerdDinner App using Microsoft Unity Application Block (Unity) v 2.0. Unity 2.0 Unity 2.0 is available on Codeplex at http://unity.codeplex.com . In earlier versions of Unity, the ObjectBuilder generic dependency injection mechanism, was distributed as a separate assembly, is now integrated with Unity core assembly. http://weblogs.asp.net/shijuvarghese/archive/2010/05/07/dependency-injection-in-asp-net-mvc-nerddinner-app-using-unity-2-0.aspx

ASP.NET MVC Request Flow

I gave a presentation Thursday at the Richmond Meet and Code. This presentation covered Microsoft’s new web app framework “ASP.NET MVC”. My presentation was actually quite short, but one of the things I wanted to show was the flow of a request into System.Web.Routing and through System.Web.MVC. I looked around on the web and I could not find one, so I ended up creating one. http://www.codethinked.com/aspnet-mvc-request-flow
One of the things my team has been working on has been a new view engine option for ASP.NET. ASP.NET MVC has always supported the concept of “view engines” – which are the pluggable modules that implement different template syntax options. The “default” view engine for ASP.NET MVC today uses the same .aspx/.ascx/.master file templates as ASP.NET Web Forms. Other popular ASP.NET MVC view engines used today include Spark and NHaml .

Introducing “Razor” – a new view engine for ASP.NET

http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx
ASP.NET MVC model binding allows you to map HTTP request data with a model. This article discusses how model binding works for various types of models (simple types, complex types, collections etc.). It also shows how to create a custom model binder if situation calls for it. http://dotnetslackers.com/articles/aspnet/Understanding-ASP-NET-MVC-Model-Binding.aspx

Understanding ASP.NET MVC Model Binding

http://buildstarted.com/2010/09/12/custom-model-binders-in-mvc-3-with-imodelbinder/ Update: Apparently this works in MVC 1 and 2 – Thanks, Mike! One of the things you’ll find yourself doing quite often is loading an object from a database or other source given an id from a url. Something along the lines of http://localhost/users/details/john and then loading the User model with the username of “john”. public ActionResult Details ( string username ) { var user = db . Users .

Custom Model Binders in MVC 3 with IModelBinder

In my current project, I had to render elements in the view based on a setting provided by the model(basically it is a configurable thing). Few clients need view element to be rendered in a particular order and few others in a different way. What we did was, saved this elements order in a settings file which could be changed based on the clients. Then created an extension to render this based on the order. This is what was I was trying to explain. for Client 1 the “ Login section ” to be displayed first followed by “ Password reminder section ” For Client 2 , these sections needs be ordered differently http://www.rajeeshcv.com/post/details/37/mvc-rendering-view-elements-in-a-specified-order

MVC - Rendering view elements in a specified order - Personal blog of Rajeesh where he shares his knowledge in computer programming and photography

ASP.NET MVC: Using Ajax, Json and PartialViews

http://www.atlanticbt.com/blog/asp-net-mvc-using-ajax-json-and-partialviews/ While working on a new ASP.NET MVC project, I had a simple objective: add a new record and refresh my View. After sifting through several sites I found several resources that lead me to accomplish my goal. I’ve compiled my result into a new sample MVC Application that I created in Visual Studio that you can download here . I’ll explain what I did using that as my reference. It’s a trimmed down version of what I did on the actual project, but it will get the point across.
http://www.joe-stevens.com/2011/06/06/editing-and-binding-nested-lists-with-asp-net-mvc-2/ Dynamically editing lists of data and binding back to the model with MVC is a little complicated as the id’s of the form elements need to all tie up for binding to succeed. Recently I had a model, which contained a list of an object, which in turn contained another nested list. Getting this to easily bind back to the model when adding to the lists dynamically was a bit of a headache so I’ll explain how I did it. This article is inspired by this article by Steve Sanderson, but I also explain how to adapt it to bind nested lists.

Editing and binding nested lists with ASP.NET MVC 2 | Joe Stevens' Blog

ASP.Net mvc 2.0 beta, supports templates feature. Templates are a way to write reusable view code. They significantly simplifies the code we need to write in views. You can read more about templates here . http://aspadvice.com/blogs/kiran/archive/2009/11/29/Adding-html-attributes-support-for-Templates-_2D00_-ASP.Net-MVC-2.0-Beta_2D00_1.aspx

Kiran Chand's Blog : Adding html attributes support for Templates - ASP.Net MVC 2.0 Beta

A while back, I went over a few of the patterns and opinions we’ve gravitated towards on our current large-ish ASP.NET MVC project, or, how we do MVC . Many of these opinions were forged the hard way, by doing the wrong thing many times until we found the “right” opinion. Of course, many of these opinions are only really valid in the constraints of our project.

How we do MVC – View models

http://lostechies.com/jimmybogard/2009/06/30/how-we-do-mvc-view-models/

ASP.NET MVC – Unit Testing JsonResult Returning Anonymous Types

Unit testing of ASP.NET MVC JsonResults can be a source of confusion. The problem arises from the fact that an Action Method itself doesn't produce any html / json / string output – it simply returns an Action Result. ASP.NET MVC then calls the ExecuteResult() method on that Action Result. The ExecuteResult() method is what causes output to be written to the Response stream. Let's take the following controller and action method for example:

ASP.NET MVC на реальном примере. Теория и вступление. / .NET

Команда Microsoft очень интенсивно развивает свои продукты и средства для разработчиков. На эту тему уже и выхлопы шуточные были, по поводу выхода новых версий фреймворков. Разработчики, которые работают в крупных компаниях, ввязаны в большие проекты в общем-то без особого энтузиазма на это смотрят, так как такие махины нельзя в короткие сроки перевести на новую версию. Может быть чревато как всплыванием багов, так и изменением всей структуры проекта, что делать не всегда получается легко. Сказанное выше, к сожалению (или к счастью), меня не касается и это дает мне возможность использовать все самое новое без оглядки на бекграунд. Проекты довольно таки обозримые, часто переводятся на новую версию безболезненно, и новые фичи начинаю внедрять уже при реализации следующей задачи в пректе.

Code Tuning .NET | Updating/Binding Model Graphs with ASP.NET MVC

This post describes issues and solutions involved when using 'complex' object graphs as models for ASP.NET MVC applications. The ASP.NET MVC Controller class has a TryUpdateModel() method that is described in the API reference on MSDN as "Updates the specified model instance using values from the controller's current value provider": protected internal bool TryUpdateModel<TModel>(TModel model)
Download the sample project to play with the code as you read this blog post. Using the DefaultModelBinder in ASP.NET MVC, you can bind submitted form values to arguments of an action method. But what if that argument is a collection? Can you bind a posted form to an ICollection<T> ? Sure thing!

Model Binding To A List

ASP.NET MVC View Model Patterns

Since MVC has been released I have observed much confusion about how best to construct view models. Sometimes this confusion is not without good reason since there does not seem to be a ton of information out there on best practice recommendations. Additionally, there is not a “one size fits all” solution that acts as the silver bullet.