Silverlight: subcontracting download and Seo Optimization Solutions

Source: Internet
Author: User
I. Subcontracting by module

Generally, large Silverlight applications are divided into multiple Silverlight projects by modules. After compilation, multiple xap packages are generated and loaded as needed. The recently developed project does not require full-site Silverlight, but aspx hybrid Silverlight. To put it bluntly, it is to embed the corresponding sub-module xap package into Aspx.

In this way, subcontracting is much simpler: directly use js to control DOM elements, modify the source in the object element, and dynamically set it to different xap to implement refreshing loading of different modules. (This is more simple than the mainstream method on the Internet: Using WebClient to dynamically download the xap package, and then reflection loading. Of course, this method is not applicable to full-site Silverlight projects)

2. Loading pages in xap through on-demand reflection

The method discussed above only solves the problem of loading different xap files on demand. But if an xap has multiple pages, how can I determine which page to display after loading an xap?

Answer: parameter input + reflection

When silvelright is embedded in HTML with object tags, you can specify some input parameters, similar to the following:

            

Note that <Param name = "initparams" value = "page = Basic. City"/> indicates that the city page is displayed after loading.

So how can we accept this parameter in SL? See the followingCode:

 
Private void application_startup (Object sender, startupeventargs e) {// check whether the input parameter if (E. initparams! = NULL & E. initparams. containskey ("page") {string _ pagename = E. initparams ["page"]; // dynamically loads the corresponding instance Assembly ASM = this based on page parameters. getType (). assembly; usercontrol _ page = ASM. createinstance (_ pagename) as usercontrol; this. rootvisual = _ page;} else {// if no parameter is input, the default page this is displayed. rootvisual = New Airport ();}}
Iii. Seo Optimization

This is a common problem for Ria applications. The preceding solution does not involve this part. By default, the xap module is dynamically loaded and different pages are loaded Based on Dynamic reflection of parameters, will not change the address of the browser, so the search engine will always think that this is a page, and eventually only one URL can be included.

To make the search engine more friendly, you can do some operations in the # part of the address bar to achieve the final effect:

If the basic. xap module is dynamically loaded and the city page in the module is displayed, we can make the address bar similar to: http: // localhost: 1223/default. aspx# Basic | basic. City

Switch to the user. xap module (that is, the user management module), and display the user page in this module, we can make the address bar similar to: http: // localhost: 1223/default. aspx# User | user. User

In this way, although all are the same default. aspx page, the search engine considers this as two different URLs and searches for two addresses.

The complete code for default. aspx is as follows:

<% @ Page Language = "C #" autoeventwireup = "true" %> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml"> 

example Source Code : http://files.cnblogs.com/yjmyzz/ReflectorXap.7z

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.