I am trying to make a silverlight application that uses RIA Services for authentication and databinding.
That is, I'd like to be able to use the login/registration forms provided in the Business Application Template, and use the drag&drop features for displaying data in datagrid on pages.
The data for the application (including membership data) is stored in an existing SQL Server database.
So I am going to create a new membership provider class that inherits the MembershipProvider abstract class from the System.Web.Secruty namespace, to work with the existing database.
1. Is this the right approach?
2. How can you configure the AuthenticationService.cs in the business Application Template to work with the newly created custom membership provider class?
Thanks in advance!
You simply need to configure your membership provider in web.config. The purpose of the provider model is to make implementations interchangeable.
see http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx
Related
I am new in MVC3. When i create a new default ASP.NET MVC 3 project template.
There is a AccountModels.cs and AccountController.cs C# class that handle data from a ASPNETDB.MDF DB file, there is a connection string (XML) in Web.config file, but i can't understand how it handle those data where is the Query or LINQ, How AccountModels.cs or AccountController.cs file know those DB tables Can anyone make me understand step by step? please someone help me please.
Sorry for my bad English.
It is using Microsoft Membership Provider.
From the doc:
ASP.NET membership gives you a built-in way to validate and store user
credentials. ASP.NET membership therefore helps you manage user
authentication in your Web sites. You can use ASP.NET membership with
ASP.NET forms authentication by using with the ASP.NET login controls
to create a complete system for authenticating users.
Basically it has quick straight forward configuration and creates a couple of tables in your database to keep user data.
It is flexible, but the interfaces are not very well segregated and if you need to extend it or plug your custom logic you may end up defining a tons of method throwing "Not Implemented" exception
I've made a service for my silverlight 4 database (SQL) affairs (VS2010, C# ASP.NET web app), now I'm writing my SQL functions in this service, how can I use this functions? I've read some articles about deploying services but I think my case should not be much complicated, I have a big ASP.net web app with several web pages (I have a server running on winserver2008), it works great, also I have a SL app, what kind of files should I upload for using service? do I need an asmx? how can I create it? should I change anything in web.config?
what is the easiest way to use my service for communicating between SQL and SL? thanks
WCF RIA Services is the way to go. You do not want to bother with old-school ASMX web-services.
You will use an EF model and a DomainContext on the server to handle all database access via CRUD methods (Create, Read, Update & Delete).
On the client you will use the generated Domain Service client to access data.
Notes from my previous RIA post:
My suggestion is to always create RIA Service libraries instead of adding directly to a Silverlight application. Then you can link the Client-side library to any number of Silverlight applications, then link the .Web part of the RIA library to your website to provide the WCF service. Again the key is to migrate the config settings.
It will probably make a lot more sense if you create a new RIA services library project, add your EDM etc, then link the halves to a separate Silverlight app and your new ASP.net website.
Step-by-step:
Create RIA Services Library project by selecting Add New Project. Select Silverlight on the left. Select WCF RIA Services Class Library on the right. I will assume it is called the default name RIAServicesLibrary1 for this example. It will create a Silverlight client library called RIAServicesLibrary1 and a standard .Net library called RIAServicesLibrary1.Web for use by the Web server.
Add your EDMX to the RiaServices.web project. Select Add new item. Select Data on the left. Select ADO.Net Entity Data Model on the right. I will assume it is called the default Model1.edmx for this example. Connect it to your database tables etc.
Build your project so that the next step will find your data model.
Create a Domain Service referencing your EDMX models in your RiaServices.web project. Select Add new item. Select Web on the left. Select Domain Service Class on the right. I will assume it is called DomainService1.cs for this example. Choose your data items from the Add New Domain Service Class popup window by ticking the checkboxes. A set of RIA services objects and methods will be created for each item you select.
Add a reference to the client Ria services library project (RIAServicesLibrary1) to your Silverlight application.
Add a reference to the web RIA services library project (RIAServicesLibrary1.Web) to your hosting web application (e.g. you ASP.Net website).
Copy/merge the various sections in the RIAServicesLibrary1.Web/app.config file into your <webapplication>/web.config file. This will include any connection strings and the module sections.
Build the project again so that the Data Source window will see your new Domain Context data sources.
Use the RIAServicesLibrary1 client object (called DomainService1 in this example) directly from your Silverlight code like this:
DomainService1 client = new DomainService1();
or use the Data Sources window to drag/drop a new grid etc onto a page.
If the Data Sources window is not visible select the "Data" menu then the "Show Data Sources" option.
For more information try this Microsoft link: Using WCF RIA Services
I am building a silverlight application using MVVM pattern but I don't understand what I am missing here...
ViewsProject (Silverlight Application) contains user controls and page. References ViewModelsProject.
ViewModelsProject (Silverlight class library) contains backend code of views. Also the business logic will reside in here. It will reference Models project.
ModelsProject (Windows class library) contains: Ado.net entity model of a local database and a WCF RIA DomainService built on the entity model. It's purpose is to get data from the local database and the entities are exposed via domain service.
Web project: Contains xap of ViewsProject.
Have I done everything correct so far? If yes then please help me understand:
How do I call the methods of the
domain service in the ViewsModel
project? If I reference the
ModelsProject, I get the error that
only silverlight projects can be
added.
If I change ModelsProject to a
silverlight class library project
then I can't add the entity model of
my database.
For client projects to use WCF RIA Service you need to set WCF RIA Services Link in project property.
As for modularity and separation in project architecture when using WCF RIA Services,
you can use WCF RIA Class libraries.
There isn't much sense in separating your views from your viewmodels IMHO. I've seen this approach used before but the view model (in my mind at least) represents a more 'view appropriate' abstraction of the data than the domain model can offer. The ViewModel provides a layer of indirection to allow the presentation to change without the model doing the same but it's little more than a sort of Adapter/Controller hybrid and lives alongside the view.
To answer your question though...
Typically, you'll have your SL project call your domain service (a web service usually) via commanding from your view to the viewmodel. The viewmodel command will then directly or indirectly make the web service call. This web service does not need to be a SL class library since it sits on the web server away from your client.
I get the feeling your thinking in terms of a desktop app here. Remember that the SL project runs client side and your data is not there. To wire all this up your gonna need some remote service to get the data from. A regular library reference is no good since the data is not on the client.
HTH, Stimul8d
I worked out the answer.
Change ViewModelsProject (Silverlight class library) to Silverlight Application type.
Check Enable Ria services during creation of the project.
In the view model class, add using ModelsProject.
Compile the ViewModelsProject.
All of the methods of the WCF Ria service will then appear in the code.
Using the Silverlight Business Application template in VS2010 creates a nice default solution with a Silverlight project and an ASP.NET project. It also automatically provides some nice authentication that seems to store usernames/password/etc for newly registered users into your local SQL Server database.
Is it possible to customize the storage mechanism? I already have a data store elsewhere and want to handle the adding/removing etc of details myself.
Yes, you can. WCF RIA Services is using the default ASP.NET Membership provider. So search on the web on how to modify them (via web.config) to connect to another source and it will be transparent for the SL/WCF RIA Services application.
For instance, I've connected them to the Azure Storage (table) instead of the default ASPNETDB database on this application : http://cloudypizza.cloudapp.net . You can test it by creating your own account on clicking on "login".
I've briefly explained how I've done it here on my blog (in French only sorry)
Regards,
David
I've seen oodles of examples for ASP.NET, but none for winforms. In other words, using the app.config instead of web.config. It would be a shame if it did not work.
It works exactly the same. The base provider model is part of System.Configuration, which abstracts (provider!) whether the application is configured via app.config or web.config.
Read about Client Application Services if you want to use ASP.NET providers in your Windows apps.
If you wish to use the Provider Pattern in a Windows app, this can also be done. I once did this to allow configuration between a real scanner and a fake one (yes I know I could of used an IOC container).
CodeProject probably has several provider tutorials- here is one: link text