Windows 2012 Hosting - MVC 6 and SQL 2014 BLOG

Tutorial and Articles about Windows Hosting, SQL Hosting, MVC Hosting, and Silverlight Hosting

Silverlight 4 WCF Hosting - ASPHostPortal :: How to Create A WCF RIA Service Using Entity Framework

clock July 19, 2011 06:42 by author Jervis

Here are directions to create a WCF RIA Service that uses a Entity Framework database. This demonstrates a web deployed application, and the method to set the connection string for the Entity Framework class in the web.config.













































Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

-
DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services



Silverlight 4 Hosting - ASPHostPortal :: How to Edit Silverlight page data using Domain Service

clock June 16, 2011 06:02 by author Jervis

This post requires to create a Silverlight Business Application in Visual Studio 2010.

1. Open the Mainpage.xaml , Add the following XAML code to see the Save changes and Reject changes button

   1: <Button Content="Save Changes" Click="SaveButton_Click"
         Margin="5" 
   2:        x:Name="SaveButton"></Button>
   3: <Button Content="Reject Changes" Click="RejectButton_Click"
               Margin="5"
   4:         x:Name="RejectButton"></Button>
   5: <TextBlock x:Name="ChangeText" VerticalAlignment="Center"
      Width="Auto"></TextBlock>

2. Add the code for button click event handlers as shown below

   1: private void SaveButton_Click(object sender, RoutedEventArgs e)
   2:  {
   3:   awDept.SubmitChanges(OnSubmitCompleted, null);
   4:  }
   5: 
   6:  private void RejectButton_Click(object sender, RoutedEventArgs e)
   7:  {
   8:    awDept.RejectChanges();
   9:    CheckChanges();
  10:  }
  11: private void CheckChanges()
  12:  {
  13:   EntityChangeSet changeSet = awDept.EntityContainer.GetChanges();
  14:   ChangeText.Text = changeSet.ToString();
  15:   bool hasChanges = awDept.HasChanges;
  16:   SaveButton.IsEnabled = hasChanges;
  17:   RejectButton.IsEnabled = hasChanges;
  18:  }
  19: 
  20: private void OnSubmitCompleted(SubmitOperation so)
  21:  {
  22:    if (so.HasError)
  23:     {
  24:         MessageBox.Show(string.Format("Submit Failed: {0}", so.Error.Message));
  25:         so.MarkErrorAsHandled();
  26:      }
  27:             CheckChanges();
  28:  }

  29: private void departmentDataGrid_RowEditEnded(object sender,
          DataGridRowEditEndedEventArgs e)
  30: {
  31:          CheckChanges();
  32: }

3. Open the Metadata file in server project and add the editable attribute to the Id and modified date as shown below

   1: internal sealed class DepartmentMetadata
   2:         {
   3: 
   4:             // Metadata classes are not meant to be instantiated.
   5:             private DepartmentMetadata()
   6:             {
   7:             }
   8: 
   9:             [Editable(false)]
  10:             public short DepartmentID { get; set; }
  11: 
  12:             public string GroupName { get; set; }
  13:             [Editable(false)]
  14:             public DateTime ModifiedDate { get; set; }
  15: 
  16:             public string Name { get; set; }
  17:         }

4. When you run the application you should be able to see the below screen



Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.


You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



Silverlight 4 Hosting - ASPHostPortal :: Making the ScrollViewer Talk in Silverlight 4

clock May 11, 2011 07:11 by author Jervis

Recently I came across the requirement to react to the fact that a user had scrolled a view to the bottom. It sounded easy at first because I imagined hooking into a scroll viewer changed event, listening to the event args, and then reacting when it was done. The only problem was that I couldn't find the appropriate event to bind to!

A quick search found that many people are having the same problem. The "important" events are hidden inside the ScrollViewer, down at the bars. A few solutions walk the visual tree down to the bars and hook in, but I wanted something that was a little more generic and clean.

Fortunately, we can get what we want by listening to properties. I'm going to give an example for the "VerticalOffset" property which shows how much the vertical scroll is offset from the height. When this equals the height, it has been scrolled to the bottom. This example, however, isn't just for scroll bars - it will work with any type of dependency property you want to listen to.

The trick is to create a binding for the property you want to listen to. Then, bind to the binding using a dependency property, and listen for that to change!

In our case, we want to watch the vertical offset for a ScrollViewer. Here is the binding:

...
var binding = new Binding("VerticalOffset") { Source = myScrollViewer };
...

Next, I want to listen to that binding and react when it changes. I can, for example, interrogate the scroll viewer and see if it's reached the bottom (note that if I wanted, I could also fire a command and indirectly bind the property change to an ICommand on a view model).

...
var offsetChangeListener = DependencyProperty.RegisterAttached(
   "ListenerOffset",
   typeof(object),
   typeof(UserControl),
   new PropertyMetadata(_OnScrollChanged));
myScrollViewer.SetBinding(offsetChangeListener, binding);
...
public void _OnScrollChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
   // do something with the scroll viewer 
}
...


That's it! You can wrap this into a behavior that you simply drop onto the ScrollViewer
and you can make even the most stubborn ones sing.

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



Silverlight 4 WCF Hosting - ASPHostPortal :: Error - This collection already contains an address with scheme http

clock May 6, 2011 08:06 by author Jervis

I often see people post this error message in the forum. So, I decide to make the post. Hope this tutorial will help

Server Error in '/' Application



This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.
Parameter name: item

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.
Parameter name: item

Solution:

The solution, since WCF services hosted in IIS can have only one Base Address was to create a custom service factory to intercept and remove the additional unwanted base addresses that IIS was providing. In my case IIS was providing:

domain.com
www.domain.com
dedicatedserver1234.hostingcompany.com

We are able to customize our .svc file to specif a custom serive factory

We are then able to create our custom factory by inheriting from ServiceHostFactory and overriding as required

    class CustomHostFactory : ServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
              CustomHost customServiceHost =
                new CustomHost(serviceType, baseAddresses[1]);
            return customServiceHost;
        }
    }

    class CustomHost : ServiceHost
    {
        public CustomHost(Type serviceType, params Uri[] baseAddresses)
            : base(serviceType, baseAddresses)
        { }
        protected override void ApplyConfiguration()
        {
            base.ApplyConfiguration();
        }
    }

In my case I decided to pass through baseAddresses[1] (which was the www. address) but it would probably be wise to specify that address you want to prevent changes by your web host from impacting your code.

For more information about Silverlight WCF RIA hosting, please visit our site at ASPHostPortal.com. Cheers!! Good luck.

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.


You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



Silverlight 4 Hosting - ASPHostPortal :: Getting Started with WCF RIA Services for Silverlight 4

clock April 4, 2011 07:03 by author Jervis

What is so great about RIA Services?

RIA Services mainly targets Business Application Development, and comes across good for this purpose from a few different angles.


1. RIA Services simplifies the traditional n-tier application pattern by bringing together the ASP.NET and Silverlight platforms. If you have ever gone through the motions of creating a WCF Service, and then adding a service reference to your Silverlight project you will quickly find that the service calls are all asynchronous, and require you to specify an OnRequestCompleated method for calls that you make to that web service. While there are asynchronous programming patterns out there most business application developers prefer the tried and true N-Tier approach. Asynchronous Method calls make N-Tier Architecture difficult

2. As stated above Ria simplifies tiered architecture this means it is a great choice for creating applications using some of the more popular architectural patterns like MVVM, and MVC.

3. Because RIA Services is from Microsoft, you get tight Visual Studio Integration, and lots of Blogs, and Documentation covering it's use. While some of the open source projects out there are pretty good, most lake adequate documentation and have a steep learning curve.

4. Ria Services is flat out great for Rapid Application Development. There is Code Generation generation built into Visual Studio to generate Domain Services directly from ADO.NET Entities Models that your Silverlight applications can consume.

Where Can I Get WCF RIA Services

You can Get Wcf Ria Services From the Microsoft Web Platform Installer, located here.

1. Highlight the Web Platform Tab
2. Scroll Down to Tools
3. Click the customize Tab
4. and check off what you need



If you don't have Visual Studio go ahead and check off to get the Express Version. You obviously want to get the RIA Services Toolkit, and while you're here get the the Silverlight 4 Toolkit, and Tools for Visual Studio as well. After the install completes you will have everything you need to work with Silverlight 4 and RIA Services from within Visual Studio.

Options for Integrating WCF RIA Services into your Projects

There are a few different way out of the box to integrate WCF RIA Services into your projects using Visual Studio

1. Using the Silverlight Business Application Project Template
2. ling RIA Services in the Silverlight Application Project Template
3. Using the RIA Services Class Library Project Template

In this post we take a look at each of these approaches, talk about when and how they are useful, and show how implement each one. For this purpose I have created a Visual Studio Solution containing each implementation listed above



In the real world you are not likely to have a solution which implements any combination of these approaches, but for this example it is nice to have them all in one place to look at.

The Silverlight Business Application Project

If you are creating an application that requires Login, Registration, and User Authentication the Silverlight Business Application Project Template is a good way to go. It includes all this right out of the box. It also has website like layout and styles you can customize and some useful helper methods. You can actually learn a few things just by creating this project and then giving it a gook look over.

To create a Silverlight Business Application:

Right Click on your Solution and select "Add New Project", Select "Silverlight" from the Tree Menu on the Left, and then Select "Silverlight Business Application".

This will create a new two Projects in you solution automatically



You now have a Web Application Project to host your Silverlight Application and Domain Services, and The RIA Link between the two projects is all set up so you can begin adding and consuming WCF RIA Services. If you run the project now you will see all the out of the box features I mentioned are there.

Configurable Layout and Styles



Login



Registration



Not bad for right out of the box. I do have a couple of small issues with this though. Sure, it's great Microsoft has given us all this stuff without having to write a single line of code, but, I would have a couple things different if it were up to me.

1. I wish the project template had a few config options upon creation. For example, for larger projects I may want all my services to be in a WCF RIA Services Class Library (RIA Class Library covered in detail below) in  instead of in the Web Application Project. Now I would have to move them.

2. I'm not really sure what kind of Architectural Pattern they are trying to implement here. As you can see from the image of the Solution Explorer above there is a folder named "Models" in both the Web Application Project, and in the silverlight project. Then there is a Views folder in the Silverlight project that has views in it, but then no ViewModels or Controllers. Okay, so my point is what are they going for here? It makes me want to start moving the code around. If I'm not alone on this please leave me a comment.

Anyway, small issues compared to the big picture.

WCF RIA Services Enabled Silverlight Application

If you don't need all the stuff that's included in the Silverlight Business Application above, or plan to just write them yourself, you can also enable RIA Services in a regular silverlight application.

To create a WCF RIA Services Enabled Silverlight Application:

Right Click on your Solution and select "Add New Project", Select "Silverlight" from the Tree Menu on the Left, and then Select "Silverlight Application".



When you click OK to add the new Silverlight Application a Dialog will appearer allowing you create a New Web Application to host your Silverlight Application in, or to host your Silverlight Application in an existing Web Project. Either way all you need to do is check the box to "Enable WCF RIA Services".



Then when your Project is created, it will already be set up to use RIA Services. You can now start adding domain services to your web project and the RIA link is in place and ready to go.

WCF RIA Services Class Library

The last option is the WCF RIA Services Class Library. In my experience the more separation you have in your solution the better. This project template allows you to house your Domain Services in separate assemblies.

To create a Solution that uses a WCF RIA Services Class Library:

Right Click on your Solution and select "Add New Project", Select "Silverlight" from the Tree Menu on the Left, and then Select "Silverlight Application".



When the project Dialog box appears allowing you to host your silverlight application in an existing or new Web Application, leave the "Enable WCF RIA Services" checkbox UN-CHECKED. The RIA Link will exist in the RIA Services Class Library.



Now right Click on your Solution and select "Add New Project", Select "Silverlight" from the Tree Menu on the Left, and then Select "WCF RIA Services Class Library".



This will actually create two projects. The RIA Services Class Library Consists of a Windows Class Library and a Silverlight Class Library and the two projects created contain the RIA Link. The project ending in .Web is the Windows Class Library and will run on the server while the other is the Silverlight Class Library will run on the client. Your solution should now look something like this.



All you need to do now is:

1. Add a reference to the Silverlight Class Library in your Silverlight Application
2. Add a reference to the Windows Class Library in your Web Application

And you are now set up and ready to start adding Domain Services to your server project for consumption in your Web Project. When using this set up you should add your domain services to you Windows Class Library section of your RIA Services Class Library.

Creating and Consuming Domain Services

Now that we know how to set up our RIA Services Project, Lets take a look at adding a Domain Service and consuming it in out Silverlight client to test that we have everything wired up correctly. In all of the scenarios listed above you will always add your Domain Service on the server side and consume that service on the Silverlight Client.

To show you how quick and easy it is to get a Domain Service up and running we are going to create a Domain Service form and ADO.NET Entities Data Model.

Start by Creating a Database. Mine consist of only one table with a very simple schema for this example.



Now right Click on your Web Project and select "Add New Item", Select "Data" from the Tree Menu on the Left, and then Select "ADO.NET Entity Data Model".



Highlight "Generate From Database" and click "Next".



Select your Target Database and click "Next".



Select the tables you want to generate the Model from and click "Finish".



Now that your Entities Data Model has been created do a Rebuild on the project before you do any thing else. This is important because if you forget to rebuild what will happen is when you go to create the Domain Service it will not be able to find your Entities. So go ahead and rebuild now and then we can create out first Domain Service.

Now right Click on your Web Project and select "Add New Item", Select "Web" from the Tree Menu on the Left, and then Select "Domain Service Class".



Click "Add" and you will get a Dialog Box Allowing you to generate your Domain Service from your entities. Select Enable Editing if you want it to Generate Update, Insert and Delete methods as well.



Now Click "OK" and it will generate your Domain Service class. It will look something like this.

[EnableClientAccess()]   
    public class ContactDomainService : LinqToEntitiesDomainService   
    {     

        // TODO:   
        // Consider constraining the results of your query method.  If you need additional input you can   
        // add parameters to this method or create additional query methods with different names.   
        // To support paging you will need to add ordering to the 'Contacts' query.   
        public IQueryable GetContacts()   
        {   
            return this.ObjectContext.Contacts;   
        }     

        public void InsertContact(Contact contact)   
        {   
            if ((contact.EntityState != EntityState.Detached))   
            {   
                this.ObjectContext.ObjectStateManager.ChangeObjectState(contact, EntityState.Added);   
            }   
            else  
            {   
                this.ObjectContext.Contacts.AddObject(contact);   
            }   

        }     

        public void UpdateContact(Contact currentContact)   
        {   
            this.ObjectContext.Contacts.AttachAsModified(currentContact, this.ChangeSet.GetOriginal(currentContact));   
        }     

        public void DeleteContact(Contact contact)   
        {   
            if ((contact.EntityState == EntityState.Detached))   
            {   
                this.ObjectContext.Contacts.Attach(contact);   
            }   
            this.ObjectContext.Contacts.DeleteObject(contact);   
        }   
    }

Notice it created services methods to preform all the CRUD opperations we need against our Database.

Now in our Silverlight project we will create a Grid in our MainPage.xaml to display our data like so:

<
sdk:DataGrid x:Name="DataGrid" Margin="12" AutoGenerateColumns="True" />

Then in the code behind (MainPage.xaml.cs) we will add the code to call our domain service and populate our grid.

1. You will need to add a using directive to the Namespace in your server project where your domain services are located.
2. Create a private instance of your DomainContext
3. In the constructor call the load method of your context and pass in your GetContactsQuery from your Domain Service
4. Set the ItemSource Property of your DataGrid to the Collection of Contacts now available in your DataContext.

using SilverlightApplication3.Web;     

namespace SilverlightApplication3   
{   
    public partial class MainPage : UserControl   
    {   
        private ContactDomainContext _context = new ContactDomainContext();  

        public MainPage()   
        {   
            InitializeComponent();   
            _context.Load(_context.GetContactsQuery());   
            DataGrid.ItemsSource = _context.Contacts;   
        }   
    }   


Now hit F5 and run the application. TADA! You should now see your data in the grid!



I hope this helped you in getting started with .NET RIA Services. I will be covering more in future posts.

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.


You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



Silverlight 4 Hosting - ASPHostPortal :: Integratng Microsoft Translator Service into Silverlight and Windows Phone

clock February 2, 2011 05:34 by author Jervis

Sample of the control in Silverlight 4 App



Sample of the control in Windows Phone 7 Application



It just has one important property you have to set, the Application Id of Microsoft Translator. You can get one here (
http://developer.live.com).



The control has two events.



To translate text from one language (de-de = Germany) into one other (en-us = English US) is extremly simple. Problems like synchronizing the background thread into the UI-Thread is hidden in the control.

The following code demonstrates the easiness of using.

private void MicrosoftTranslator_Translated(object sender, TheOliver.Controls.TranslatorEventArgs args)
{
    _out.Text =args.TranslatedText;
}

private void MicrosoftTranslator_TranslationError(object sender, TheOliver.Controls.TranslatorErrorEventArgs args)
{
    _out.Text= args.Error.Message;
}

private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
    _mts.Translate(_in.Text, "de-de", "en-us");

Here is the complete code of the Microsoft Translator Service:

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace TheOliver.Controls
{
    public class MicrosoftTranslator : UserControl, InotifyPropertyChanged
    {
        private string _appId;
        public string AppId
        {
            get { return _appId; }
            set { _appId = value; }
        }

        private bool _isBusy = false;
        public bool IsBusy
        {
            get { return _isBusy; }
            set
            {
                _isBusy = value;
                OnPropertyChanged("IsBusy");
                this.IsIdle = !_isBusy;
            }
        }

        private bool _isIdle = true;
        public bool IsIdle
        {
            get { return _isIdle; }
            set
            {
                _isIdle = value;
                OnPropertyChanged("IsIdle");
            }
        }

        private byte[] _bytes;

        public MicrosoftTranslator()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                StackPanel sp = new StackPanel();
                sp.Background = new SolidColorBrush(Colors.Red);

                TextBlock tb = new TextBlock();
                tb.Text = "[Microsoft Translator Service]";

                sp.Children.Add(tb);
                this.Content = sp;
            }
        }

        public void Translate(string sourceText, string sourceLanguage, string targetLanguage)
        {
            if (this.AppId == string.Empty || this.AppId == null)
            {
                MessageBox.Show("No AppId for Translator service defined. You can get an AppId at http://dev.live.com.");
                return;
            }

            this.IsBusy = true;

            // Creating a string with the request URL
            // The URL includes the Bing developer appId and in this case hardcoded to translate from
            // English to Spanish
            string translateUri =             "http://api.microsofttranslator.com/V1/Http.svc/Translate?appId=" + _appId
                + "&from=" + sourceLanguage
                + "&to=" + targetLanguage;

            // Create a web request to the URL
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(translateUri);

            // Set the request method to POST
            httpWebRequest.Method = "POST";

            // Set the content type (needs to be text/plain for POST methods)
            httpWebRequest.ContentType = "text/plain";

            // Encode the txtInput value bytes for the POST
            _bytes = Encoding.UTF8.GetBytes(sourceText);

            // Create a stream for the request
            httpWebRequest.BeginGetRequestStream(new AsyncCallback(OnGetRequestStream), httpWebRequest);
        }

        private void OnGetRequestStream(IAsyncResult iar)
        {
            try
            {
                HttpWebRequest httpWebRequest = (HttpWebRequest)iar.AsyncState;
                Stream os = httpWebRequest.EndGetRequestStream(iar);

                os.Write(_bytes, 0, _bytes.Length);

                if (os != null)
                {
                    // Close the stream when finished
                    os.Close();
                }

                // Send the request and get the response
                httpWebRequest.BeginGetResponse(new AsyncCallback(OnGetResponse), httpWebRequest);
            }
            catch (Exception exc)
            {
                RaiseError(exc);
            }
        }

        private void OnGetResponse(IAsyncResult iar)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)iar.AsyncState;

                if (!iar.IsCompleted)
                {
                    Debug.WriteLine("Not completed");
                }
                WebResponse response = request.EndGetResponse(iar);

                // Open a stream for the response
                Stream stream = response.GetResponseStream();
                StreamReader reader = new StreamReader(stream);

                // Create a string for the contents of the web response
                string output = reader.ReadToEnd();

                // Return the output string
                OnTranslated(output);
            }
            catch (Exception exc)
            {
                RaiseError(exc);
            }
        }

        public event TranslatorEventHandler Translated;
        public event TranslatorErrorEventHandler TranslationError;

        private void OnTranslated(string output)
        {
            this.IsBusy = false;
            if (Translated != null)
            {
                Dispatcher.BeginInvoke(() =>
                    {
                        TranslatorEventArgs args = new TranslatorEventArgs();
                        args.TranslatedText = output;
                        Translated(this, args);
                    });
            }
        }

        private void RaiseError(Exception exc)
        {
            this.IsBusy = false;
            if (TranslationError != null)
            {

                Dispatcher.BeginInvoke(() =>
                    {
                        TranslatorErrorEventArgs args = new TranslatorErrorEventArgs();
                        args.Error = exc;
                        TranslationError(this, args);
                    });
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                Dispatcher.BeginInvoke(() =>
                    {
                        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                    });
            }
        }
    }

    public delegate void TranslatorEventHandler(object sender, TranslatorEventArgs args);

    public class TranslatorEventArgs : EventArgs
    {
        public string TranslatedText { get; set; }
    }

    public delegate void TranslatorErrorEventHandler(object sender, TranslatorErrorEventArgs args);

    public class TranslatorErrorEventArgs
    {
        public Exception Error { get; set; }
    }
}

I hope you like this sample and the translator app.

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

-
DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



Silverlight 4 Hosting - ASPHostPortal :: Deploying a Silverlight 4 App Connected to a Database

clock January 25, 2011 05:31 by author Jervis

Error Message:

"System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed fore query 'GetProducts'.... Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed"

You can see this picture below that we have finished configure our Silverlight app using VS 2010 and .NET 4 framework.


Now, go to deploy the application.

Then open your inetmgr. The IIS Manager Window will show up. GO to MIME types.

In the appearing list, we’ll need to include the following types (XAML, XAP, XBAP) as shown in the image below


Now, in the left menu, let’s go to Sites, and let’s add our Web Site (as default site, virtual directory… based on our own needs). When done, let’s click in our application, like this:


If ASP.NET v4.0 is not selected, and you leave
DefaultAppPool
as I did in the beginning, you will get the following error message every time your application tries to connect with the database: “There is an error in the service with the Get function..”

So, now that we selected our Application Group, let us configure it. In the left panel (back in the IIS Manager Window), right above our Default Site, we’ll see “Application Groups”. Click it. A list will appear in the center panel. Let’s open the ASP.NET v4.0 and select the right framework version. Click ok and select it again, but instead of opening it, this time we’ll go to the right panel, and we’ll click on “Advance Configuration”:


Change the Local System and select Network Service, as shown in the image above. And that’s it! Now we are able to access our data from our Silverlight 4 application without getting any error from the Web Server.

Hope it helps!!

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.


You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



About ASPHostPortal.com

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions


Author Link


Corporate Address (Location)

ASPHostPortal
170 W 56th Street, Suite 121
New York, NY 10019
United States

Sign in