Found how to Redirect Silverlight to HTML5 site by mobile detection code
Hello Everyone!
I just wanted to post something I developed, that's super useful.
I posted this in the Silverlight forum (https://support.geocortex.com/SupportForums/Thread.aspx?pageid=0&mid=2&ItemID=7&thread=52364), but it's also pertains to HTML5 so I wanted to put it here.
So the original issue I had was that for some reason, using the iFrame to reassign the URL caused the buttons & map interface on my HTML5 site's to shrink.
The solution I came up with solves 2 of my problems, with 1 piece of code:
1) I setup a way for Mobile Detection, so if people are trying to access the Silverlight version of a site, the code will detect whether or not they are using a mobile device. If so it will then re-direct them to the mobile version of that site. We had to do this because we are supposed to be developing all new sites on a 'technology agnostic platform', meaning for every Silverlight map site we develop, an HTML5 mobile version must also be created.
2) Keep the Mobile site's from shrinking in size due to the iFrame's URL re-assignment
-------------
1) First I wrote a Default.aspx file and placed it in the Desktop (Silverlight) version of our map site's folder in Inetpub\wwwroot.
The code in it is the following:
<!DOCTYPE html><meta content=“width=device-width, initial-scale=1, maximum-scale=1”>
<script runat="server" language="c#">
private static string[] mobileDevices = new string[] {"iphone","ppc", "ipad",
"windows ce","blackberry",
"opera mini","mobile","palm",
"portable","opera mobi"};
public void Page_Load(Object sender, EventArgs e)
{
if (Request.Browser["IsMobileDevice"] == "true" || mobileDevices.Any(x => Request.ServerVariables["HTTP_USER_AGENT"].ToLower().Contains(x)))
{
Response.Redirect("http://testmapit.fortworthtexas.gov/Html5Viewer_1_2/Handheld.html?viewerConfigUri=http://testmapit.fortworthtexas.gov/Geocortex/Essentials/REST/sites/mZoning/viewers/mZoning/virtualdirectory/Resources/Config/Default/Handheld.json.js");
}
else
{
Response.Redirect("Default.htm");
}
}
</script>
2) Then I went into IIS and made the Default.aspx file the first file that was read, in other words I made it the Default Document.
3) Then I copied the same Default.aspx file & placed it in the Mobild (HTML5) map site's folder in Inetpub\wwwrooot, and I also went into IIS and made sure it was the Default Document.
Hopefully this helps someone else, good luck!!
Laura
-
Does this work if you have multiple sites? Or does this only apply for a single site. I'm obviously not a programmer.
Jared
0 -
I'm not a really a programmer either, but I pick up some random bits & pieces as I go along. I've never tried it on more than 1 site at a time. The way I have it setup, you have to configure it for each Desktop & Mobile site combo in the Desktop site's wwwroot folder. Or did you mean something else? -Laura-
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
2 kommentarer