.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Using MEF to RegisterRoutes (Many Models)

Posted By:      Posted Date: October 27, 2010    Points: 0   Category :ASP.Net

I was toying with the idea of using the Managed Extensibility Framework to dynamically "plug-in" and Register Routes

say we have a factory to compose part like so - this example only returns 1 model but you get the idea:

using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;

namespace MyModels
    public sealed class ModelFactory
        public ModelFactory()

        private void ComposeParts()

View Complete Post

More Related Resource Links

could somebody give me example how I can connect to database only once if I use many models in contr


I use in my ASP.NET MVC application repository pattern and I use in controller for example 3 models:

   namespace MvcApplication1.Controllers  
        public class HomepageController : Controller  
            private IWebsitesRepository _repository_websites = new WebsitesRepository();  
            private IFirmRepository _repository_firm = new FirmRepository();  
            private IPhotosRepository _repository_photos = new PhotosRepository();  

In WebsiteRepozitory, FirmRepository and PhotosRepository classes I have:

Database1Entities _entities = new Database1Entities();

So I have 3 connections to database ? Is it wrong ? How can I solve it ?

Need To Create A Mobile App for All Mobile's Models, No WAP Browser Intrection


Hi all,

I have an assignment to develop a mobile application for My company's customers (around 250000). its could be download from our website or we can also provide to our customers those are visiting our branches, on their demand.


1- this application should execute/compatible with all kind off mobile phone (Nokia, Samsun, LG, Motrola, Black Berry, iPhone..... every one). when it install on customer phone it will provide some certian option under the my company Icon to the user, like:

         1- Help Line Numbers

         2- Branches Address/Details

         3- My Last Visit Informations.

         4- My Next Appointment.

         5- My Payment History   and more etc etc......

         the user will select any one option and then get the response by return text Message against the option he selected from our Site/Service (I dont konw what we will say this system who will response to the customers)

My Problem is that I saw/Check many fourms and articals they are giving the tips/det

Domain Models: Employing the Domain Model Pattern


In this article, we'll go through the reasons to (and not to) employ the domain model pattern, the benefits it brings, as well as provide some practical tips on keeping the overall solution as simple as possible.

Udi Dahan

MSDN Magazine August 2009

Security Briefs: Threat Models Improve Your Security Process


Using threat models to drive your security engineering process helps prioritize the code review, fuzz testing, and attack surface analysis tasks.

Michael Howard

MSDN Magazine November 2008

Foundations: Loading Workflow Models in WF


When building workflows, you must consider the developer experience, available tools, long-term maintenance, and future versioning.

Matt Milner

MSDN Magazine May 2008

Memory Models: Understand the Impact of Low-Lock Techniques in Multithreaded Apps


Because the use of low-lock techniques in your application significantly increases the likelihood of introducing hard-to-find bugs, it is best to use them only when absolutely necessary. Here Vance Morrison demonstrates the limitations and subtleties low-lock techniques so that if you are forced to use them you have a better chance of using them correctly.

Vance Morrison

MSDN Magazine October 2005

.NET Zero Deployment: Security and Versioning Models in the Windows Forms Engine Help You Create and


Windows Forms applications solve many of the problems inherent in building Web applications the old fashioned way?with HTML. To demonstrate the use of Windows Forms over the Web, the author takes his existing app, Wahoo!, and ports it to Windows Forms. In doing so, he discusses versioning, linked files, security, storage isolation, the deployment model, and everything else you need to get started building your own Windows Forms apps for the Web.

Chris Sells

MSDN Magazine July 2002

Security: Unify the Role-Based Security Models for Enterprise and Application Domains with .NET


Role-based security allows administrators to assign access permissions to users based on the roles they play rather than on their individual identities. These privileges can be used to control access to objects and methods, and are easier to identify and maintain than user-based security. The .NET Framework provides two role-based security models, which are exposed as two namespaces: System.Enterprise-Services and System.Security.Permissions. Presented here is a comparison of the two options and a discussion of when each is the right choice. The author also demonstrates the process involved in setting up access security and discusses role memberships.

Juval Lowy

MSDN Magazine May 2002

Video: Creating Custom Ranking Models in SharePoint 2010 Search

In SharePoint search you can tune the weighting that search uses for the results and create custom ranking models to return the results the user is expecting. (Length: 2:28)

Collection is read-only Arrays in models

I'm about to pull my hair out with this one. I have a model with 2 arrays of inputs that looks like this public partial class MyModel : MyModel { public double?[] Array1{ get; set; } public double?[] Array2; public MyModel() { Array1 = new double?[10]; Array2 = new double?[10]; } }Now, if I change Array1 to look like Array2 (Remove the accessors) I don't get an error, However after posting the data all the elements in the arrays are null. Now if I do either of the arrays like Array1 above, Exception Details: System.NotSupportedException: Collection is read-only.What am I doing wrong here?    public partial class TimesheetWeekModel : TimesheetBaseModel     {         public double?[] Hours { get; set; }         public double?[] Miles;         public TimesheetWeekModel()         {             Hours = new double?[7];             Miles = new double?[7];         }     

WPF 3D models and transfoms

Hi all! I'm building on 3D object which containg a bunch of different objects. The way i build it is mostly in c#. meaning the basic viewport3d is in the xaml part, but the modelVisual3Ds are built in c# (since there are to many caluculations....). building the objects this way coasec a couble of complications:  - When i wanna perfom animations on these object - i have no way to call them (since they have no name) - some actions are applied only when clicking a certain object, how could i know what object was clicked? Besides i have another question about transforming. for example: when i want to rotate an object, and after that action is done to rotate it again, how do i make sure the first transformation in not deleted by the next trasformation? hope my questions are clear enough!! Any answer would be helpful thanx in advance!

MVC2 Could not load file or assembly 'xxxx.Models' shared hosting

Hello,I have an mvc2 site that runs fine locally but when i deploy it to my shared hosting account i keep getting this error.Could not load file or assembly 'AppMVC2.Models, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.I have run Reflector againts the dll to see what dependencies the dll has, I then took each one of the dependant dlls and set them to copy local in the project and deployed them all to the shared hosting account even ones that should be on the server like System.Web. except for mscorlib.dll, but i still get the error.I have also tried to bin deploy and deploy the code files and get the same error.I have seen people write about fusion log but i don't see any examples on how to get this running on shared hosting.Just wondering does anyone else have any recommendations on how to track down the source of this problem?

Two models passed to a one view ?

Hi, I'm new to ASP.NET and mvc world, so I may be a dumb question... I'm trying to develop my application and I've got a master page where I'm planning to create a div container, where my "news" will be loaded from my database and will be shown always on a main site. Then inside of the main placeholder I'm planning to load some extra data too from my database... and there's the question: how to solve that ? is there any possibility to pass a model to a master page ? or two viemodels to a view page inside the main placeholder on my page ? (one with news, and other containing some other data). Show me the way :) Thanks, Gregory

The model of type 'ProductSystem.Models.Product' could not be updated. Part 2

This is related to this thread:  http://forums.asp.net/t/1596813.aspx I am getting "The model of type 'ProductSystem.Models.Product' could not be updated. " on the line UpdateModel(product, "product",  collection.ToValueProvider());or UpdateModel(product, "product",  collection); Ugh.. My view model that i passed to the view is:using System.Collections.Generic;using ProductSystem.Models;namespace ProductSystem.ViewModels{    public class ItemEditViewModel    {        public Product product {get; set;}    }} The contoller code is:         public ActionResult Edit(int id)        {            ItemEditViewModel ItemEditVM = new ItemEditViewModel();            try{                     ItemEditVM.product = storedb.Products.Single(a => a.Product_Key == id);                    TempData["Error"] = "";          &nbs

Entities Data Models with multiple Categories using a membership table

(Using SQL Server 2008 and ASP.NET MVC2) I have a simple business table and a category table. I have a 3rd table to map business to category, a many-to-many relationship. the Map table contains a BusinessID and CategoryID. I'm lost as to how I can load the categories into my Business View Model using the entities model.Without incorporating categories, my code looks like this: var businessList = from b in entitiesDB.Businesses select new Models.BusinessViewModel { BusinessID = b.BusinessID, Name = b.Name } with Business View Model defined as: public class BusinessViewModel { [ScaffoldColumn(false)] public Guid BusinessID { get; set; } public string Name { get; set; } public List<Models.CategoryViewModel> Categories { get; set; } } but if i want to populate the Categories with the mapped categories, how would one do that?Thanks in advance for any help!

BDC Models - Pass parameters to ReadList() method?


Hi Guys,

I have some BDC models built and they work great within Sharepoint. I have one list, for example, which lists all Institutions listed in the DB.
On the following page (Everything you need to know about BDC) they show a customers list with search options at the top of it. Is it possible to get that working in Visual Studio? I've tried using filters, but it appears as those values are hard-coded from the List Settings page.
Any thoughts on how to achieve something similar?

Next challenge is to figure out how to get one-to-many relations ships working for reading data, and then for writing data (an institution can have multiple addresses, for example). But that's for another day :)


I wrote a book :) http://www.amazon.com/Microsoft-Visual-Studio-2008-Programming/dp/0071604081

How to Move Controllers/Models into a New Project/Assembly in MVC 2?


I have to admit first, that for the last few years, I've been mostly an MVP guy versus MVC. However, how I used to implement MVP is very similar to how MVC 2 is now implemented. I only have one issue with it...

When I used to create MVP apps, I could put all my logic (presenters, models) into separate assemblies/projects in the solution and my views into the main web app. This allows me to change the UI (i.e. the web based UI) to something else like a smart client or Silverlight or whatever and still have everything just work. With MVC 2, everything is all in the same project: controllers, views, models. Areas looked like a good start, but ultimately, not what I was looking for.

So, here's my question... How do I move the controllers and models out of the web project and into their own projects and still have everything work? A good, simple example would be the default MVC 2 web application template. When you open a new (non-empty) MVC web application, it creates a basic site for you. From there, how could I move the controllers and models in separate projects and still have everything just work? I can't seem to find anything on this anywhere else which has brought me here seeking help.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend