Question

I want to create an application that has both an ASP.NET MVC 3 web client and a Windows Phone 7 phone client. The application data is stored in SQL Server and needs to be accessed from both clients.

Given that scenario, I have two questions:

  1. I want to reuse the view models I use in the (existing) MVC application in my phone app and validate these using FluentValidation. Am I supposed to create a new class library called ViewModels and reference it in both client projects, or is there a better way?
  2. Would it be appropriate to create a Web Service that both clients talk to? Or is it better to access the data via the MVC web project?

How would an appropriate solution structure for that scenario look like?

Was it helpful?

Solution

Am I supposed to create a new class library called ViewModels and reference it in both client projects, or is there a better way?

Yes. Except you can't. Or well, you can, but you need two different project types for this. I'll recommend using shortcuts in one of the projects.

a "Windows Phone Class Library" isn't accessable from ASP.NET, and visa-versa.

Would it be appropriate to create a Web Service that both clients talk to?

Yes, very appropriate

Or is it better to access the data via the MVC web project?

You could host the web-service in your web-project. But a seperate service is easier to maintain, if you have the ability to host it.

With RestSharp you could easily integrate it with ASP.NET MVC.

OTHER TIPS

  1. You can create a library that contains the viewmodels and is used by both client projects if it is a Portable Class Library. (They were created for just this scenario.)

I know FluentValidation has support for WP7 but I'm not sure of the differences in that version or if you'll need to do anything special to work with a PCL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top