Tuesday, October 20, 2009

Sell Used Zumex For Sale

Business Application example for Silverlight 3. NET and RIA Services. - Part 4: SEO, export to Excel and Excluding browser

Part 4: SEO, export to Excel and Excluding Browser

This exercise requires (everything is free and will remain):

1 - VS2008 SP1 (including Sql Express 2008)
2 - Silverlight 3.0
3 -. NET RIA Services July'09 Preview (for this exercise, this is optional)

The original English is available here: Part 4: SEO, Export to Excel and Out of Browser
The online application is available here: http://www.hanselman.com/abrams/ # / Home


You can download the complete solution here: MonApplication.zip

Today we will discuss the various views and logic of our application. Different views



Now, let's put a different view to our application. One of the key elements to achieve different views are deep links. See how to add it to our application.



First, we need to add a Textbox to show the deep connection to each of our great employees. To do this, add the following code just after the closing tag of DataForm .



Add event SelectionChanged our Datagrid.


And
's login in the code behind ...





Now we must make the page smart enough to know this deep connection :



Now run the application, make a copy and paste this address in a browser that will show exactly this record.



Ok, now that we have a deep connection, what can we do with it? Well, we can send this link by email, instant messaging, include it in a blog, etc..

But what if we want the search engines are able to find records in our site? It turns out there for this a standard format called sitemap ( http://sitemap.org/ ). You can see a concrete example here: http://amazon.com/robots.txt .

To add it to our application, do a right click on our web project, Add New Item, Search Sitemap.



This adds robots.txt and sitemap.aspx to our project. Before proceeding further, we will use the Default.aspx page your homepage. To do this, we will make a copy / paste the entire contents of the file in BusinessApplicationTestPage.aspx Default.aspx. Once done, check that the first two lines of the latter are well read:



Then go to Project , MonApplication.web Properties ... Make sure you have MonApplication.web highlighted.



Finally, go to the Web tab and delete the field Start Action - Specific Page



This in order that the application uses rather Default.aspx page instead BusinessApplicationTestPage.aspx your homepage.
Finally, changing the method dataGrid1_SelectionChanged to no longer refer to BusinessApplicationTestPage.aspx as follows:



This being done, see how to customize the file sitemap.aspx. Note that we use a new ASP.NET datasource control which is designed to work with the class DomainService. This gives us access to the server to the same logical application of ASP. NET and Silverlight

Let us in sitemap.aspx file to add the following code:



One last thing to do is to allow the server side to access the ID of the employee. In Default.aspx.cs , add:


Now, right clicking on sitemap.aspx , made View in browser.



And here's the result:



Change the address by Robots.txt and you should get this:



If you copy and paste an address sitemap, you can see that it works perfectly.



Ok, this works perfectly. Now, search engines can find any entity in our application. But that search engines will find it really like that? Search engines are powerful for analyzing html, but dynamic content such as those we have here or Ajax sites are more difficult to treat for them. The art of this type is called SEO Optimization for search engines (SEO, Search Engine Optimization in English, we will use here the term SEO ).

Let us in our Default.aspx page . Since we have modeled our application logic in a class DomainService, it is easy to add a standard HTML view. Just add the following code in the tag object in Default.aspx.



We also need a method domain GetSuperEmployee to support this code. So back in our SuperEmployeeDomainService.cs and add:


Now we must turn our Silverlight browser because search engines do not have this plugin.



and perform a refresh the page on a deep bond ...



Rather nice, eh? Now the search engines (with or without Silverlight) can access the data.

But does this work really? Try the following searches:

Super Alfred Employee (Yahoo) Super

Used Alfred (Google)

Well, this is a server view, let's try a different view on the client side ... We will export this data in Excel!

To do this, we will add the file excelTemplate.txt to the project root attacks. (You can download this file here: http://pagesperso-orange.fr/aristidi/files/excelTemplate.txt )

Then we'll add a button in our file Home.xaml to export to Excel:



Finally, we will write the Excel file ... notice that everything is secure, the user must select the destination file. The developer will no longer have access to the site file. Now in our Home.xaml.cs file, add the following method:



Finally, let's run the application again (after having thought to reactivate Silverlight in your browser).




This
create an Excel file where we have chosen.



Let's open it and do a little formatting.



And now for the final out of the browser ...

's select properties on the client application:



Editons parameters:



Let's start the application. Perform a right click and select "Install Application ...."






Let's add a link on the desktop ...



And it remains for us to launch the application!

0 comments:

Post a Comment