Why Silverlight?

by Sander Gerz November 14, 2009 20:05

Here’s a video I shot at the Silverlight panel discussion at TechEd Europe 2009 in Berlin.

Question was: what is the problem that Silverlight is trying to solve?

From what I could get out of the answers, the idea is threefold:

  1. Silverlight is a solution to line of business applications that, for reasons of reach, need to run in the browser.
  2. Silverlight is a media platform that support DRM and (live) streaming capabilities.
  3. Silverlight is a better alternative to Flash, especially for developers that are comfortable with the .NET Framework and languages such as C# and Visual Basic.

These answers were not given all at once in this particular video, but it became more clear during the rest of the discussion.

Are the reasons mentioned here valid, and what’s your reason for using Silverlight?

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Add bindings to a website (quickly)

by Sander Gerz August 18, 2009 11:58

As you know, IIS 7 is a powerful webserver. Just last month, after only three months of development time, we deployed the new website http://www.beurs.nl/ on an IIS 7 platform (with SQL Server 2008 back end).

This site, with over 7 mln pageviews/months, was built using ASP.NET MVC and Entitity Framework. A technology decision we haven't regretted. One advantage of ASP.NET MVC was the relative ease to support old urls that were still in use by other websites, and search engines. This meant that a url like http://www.beurs.nl/frame2.php still works. Sure, you can do that with simple URL rewriting, but obviously there are other advantages to using ASP.NET MVC. The webservers (three, load balanced) also run other sites, such as one for creating charts and another for the back-end CMS.

When figuring out which legacy urls to support, we found that the previous site had multiple aliases, such as koersen.beurs.nl, koersen3.beurs.nl, ticker.beurs.nl, etc. If we had a dedicated ip address for the primary site, and seperate ones for the other sites on the server, we could simply use a wildcard for all hostheaders. But... we do not. As a result, we needed to add each hostheader individually. The way to do this is described in this post. Though not difficult, it's quite a pain to do for 15 hostheaders, on three webservers. Yes, it's possible to share IIS 7 configuration, but we preferred not to. We do use DFS to mirror the website-folders.

As it turns out, it's not too difficult to add these binding from the command prompt:

c:\Windows\system32\inetsrv\appcmd.exe set site /site.name: www.beurs.nl /+bindings.[protocol='http',bindingInformation='*:80:forum.beurs.nl']
c:\Windows\system32\inetsrv\appcmd.exe set site /site.name:
www.beurs.nl /+bindings.[protocol='http',bindingInformation='*:80:grafieken.beurs.nl']
c:\Windows\system32\inetsrv\appcmd.exe set site /site.name:
www.beurs.nl /+bindings.[protocol='http',bindingInformation='*:80:koersen.beurs.nl']
...
etc


A simple script that takes 30 seconds to make and 2 seconds to run. AppCmd.exe is the single command line tool for managing IIS 7.0  that every developer/it pro should know.

 

Currently rated 3.4 by 5 people

  • Currently 3.4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

OpenSpaceCode code

by Sander Gerz June 06, 2009 11:01

These are the sessions for the OpenSpaceCode day.

image

Currently rated 3.4 by 5 people

  • Currently 3.4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Back to one week of TechEd Europe

by Sander Gerz May 12, 2009 17:25

Even though the Dutch Microsoft DevDays are still ahead of us, here’s a chance to look even further at TechEd Europe 2009. This year, it will be hosted in Berlin. But what is more surprising is the change back to a single week forwall both developers and IT pros. I certainly welcome this decision, and was never happy with the split that was made in the last few years. Even though I’m more active as a developer, I certainly spend a lot of time on managing a mixed Exchange 2003/2007 environment, and Windows Server 2003/2008 and need to help out every once in a while to troubleshoot on infrastructure.

But it would not only be for my personal benefit. I think it’s important and interesting for developers and IT pros to be able to see what’s happeing on the other side of the ‘fence’. Mark the dates in your calendar: 9-13 November 2009.

Currently rated 3.3 by 7 people

  • Currently 3.285714/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Working around "Cannot create an object of type 'System.Boolean' from its string representation"

by Sander Gerz April 18, 2009 21:05
In ASP.NET Web Forms most times there’s a need to set ASP.NET Server Control properties at runtime. This, for instance:
<asp:Button runat="server" id="Button1" visible="true" />

It is pretty straightforward to set the value of the visible-property in a code-behind page, like so:

protected void Page_Load(object sender, EventArgs e)
{
Button1.Visible = false;
}

However, it would be nice if you could to things like this

<asp:Button runat="server" id="Button1" visible='<% =User.IsInRole("Editor")%>' />

One might expect that that the expression above is evaluated such that the visible-property is true when the current User has the role of Editor and false if not. Unfortunately, executing this bit results in an exception:
Cannot create an object of type 'System.Boolean' from its string representation
'<%= User.IsInRole("Editor") %>' for the 'Visible' property. 
These problems are discussed also here and here. The reason is that the string-value of each property on a server-control is evaluated and parsed to its desired type. So you could set the property to "True" or "true", but not to an expression that needs to be evaluated.
The solution is to use a databinding syntax, which is pretty easy to do
<asp:Button runat="server" id="Button1" visible='<%# User.IsInRole("Editor") %>' />

As you can see, we simply add the pound/hash sign and remove the equals from the expression. This databind-expression is interpretered quite differently at runtime.

  • <%= %> is in reality the same thing as Response.Write().

  • <%# %> is more in related to assigning a value to an object. In the ASP.NET lifecycle, the <%# %> operators are evaluated before the page writes the first byte to the response buffer.

The problem with using a databinding expression is that you need to execute a DataBind() method either on the control itself or on the entire page. Executing DataBind() at page level can have negative side effects when you have multiple controls on the page with associated databinding logic. DataBind() at pagelevel triggers events, perhaps at times when you don’t want them. Using DataBind() in the codebehind for relevant controls defeats the idea a bit that we want to set a property with some simple rules and preferably in one place only.

A solution for this is to add another property (or attribute if you will), that just executes DataBind() on the current control. Something like this:

<asp:Button runat="server" id="Button1" visible='<%# User.IsInRole("Editor")%>'
code='<% DataBind(); %>' />

 

Unfortunately, that doesn’t work, because at runtime, the ASP.NET rendering engine will complain that a Button-control doesn’t have a property “code” so it doesn’t know what to do with it. However, we can trick it to ignore the property for rendering, but still execute the code, like so:

<asp:Button runat="server" id="Button1" visible='<%# User.IsInRole("Editor")%>' meta:code='<% DataBind(); %>' />


Prefixing the attribute with the text meta: with make the renderer ignore the value, but the code will still execute. Please note that the example uses meta:code, but it doesn’t really matter what name you give the attribute. It could be meta:execute or meta:whateveryouwant, as long as it’s not meta:resourceKey, because that property has special meaning.

It may not be the most elegant solution, but hey, if it works, I’m ok with it. With the rise of ASP.NET MVC we’ll probably see more of this type of coding anyway.

Currently rated 2.9 by 17 people

  • Currently 2.941176/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

.NET

Sharepoint Designer 2007 free download

by Sander Gerz April 04, 2009 10:55

Yes, that’s right. If you are working with Sharepoint, you can download the designer for free. Here’s where you can donwload it: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=baa3ad86-bfc1-4bd4-9812-d9e710d44f42

Currently rated 2.4 by 5 people

  • Currently 2.4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Renewed as an MVP

by Sander Gerz April 02, 2009 11:45

For some reason, the e-mail took a detour, but I got it (thanks Gerard):

“Congratulations! We are pleased to present you with the 2009 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others.”

Beside the recognition for past efforts, it also  feels as a stimulus to continue. Although.. I enjoy writing and helping out anyway. Nonetheless, recent projects like www.vaderradar.se, www.sat24.com, www.niederschlagsradar.de, and especially www.360.org have taken a bite out of my available time.

I’ll be hanging around the community area at the upcoming DevDays. This year, the event is around the corner from my house. Excellent! Hope to see you there.

Currently rated 3.1 by 7 people

  • Currently 3.142857/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET MVC 1.0 Final Release

by Sander Gerz March 18, 2009 17:00

I will certainly not be the first, nor the last, but here it is. ASP.NET MVC 1.0 final version is released.

Download ASP.NET MVC 1.0 here.

Currently rated 3.2 by 9 people

  • Currently 3.222222/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Javascript compressing and more

by Sander Gerz March 17, 2009 09:14

Guillermo writes about a website that can compress javascript files. It does a really good job, but when I downloaded the result, it was unreadable.

O="functioresultarkervar conercatch(    windowoundstionif(atTemp uetails r){}eh
 

Would a browser still understand what to do? Well, it certainly did. Just make sure that you need to define the charset for the script:

   1: <script src="[yourscript]" type="text/javascript" 
   2:     charset="ISO-8859-1" ></script>
 
So not only is your javascript compressed, it’s also obfuscated in such a way that others cannot easily see what it’s doing or make modifications for their own purpose.

Currently rated 2.7 by 7 people

  • Currently 2.714286/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Migration to BlogEngine.NET

by Sander Gerz March 16, 2009 19:06

It was about time I migrated my weblog, based on .Text version 0.95 to a more modern blogging platform. As you will probably know, the codebase of .Text was integrated to Community Server ages ago. I doubt whether much of that original code is still alive in CS, if any at all.

Anyway, both BlogEngine.NET and dasBlog seemed like good alternatives. Subtext too. I decided to go with BlogEngine.NET. It’s not that I did extensive research on all the options, as long I was able to migrate the content and use Live Writer for posting. A post by Erik Lane helped me through it. He also posts instructions on how to keep old links working. I didn’t want to mess in the code of BlogEngine.NET, so after updating the BE.NET database, I just added the following hack to global.asax:

    protected void Application_BeginRequest(object sender, EventArgs e)

    {  

        HttpContext context = HttpContext.Current;

       

        // Handle .Text rss feed requests.

        if (context.Request.Url.PathAndQuery.ToLower().Contains("/rss.aspx"))

        {

            context.Response.Redirect("syndication.axd", false);

            context.Response.StatusCode = 301;

            context.Response.End();

        }

       

        // Handle .Text requests from archived posts

        if (context.Request.Url.PathAndQuery.Contains("/archive/"))

        {

            // lookup post

            int dotTextPostId = GetPostId(context.Request.Url.PathAndQuery);

            System.Collections.Generic.Dictionary<int, string> posts = GetPosts();

 

            string relativeLink = string.Empty;

            if (posts.ContainsKey(dotTextPostId))

                relativeLink = posts[dotTextPostId];

               

            string redirUrl = string.Format("{0}://{1}{2}",

context.Request.Url.Scheme, context.Request.Url.Authority,

relativeLink);           

            context.Response.Redirect(redirUrl, false);

            context.Response.StatusCode = 301;

            context.Response.End();

        }

    }

 

    private static readonly Regex DOTTEXT =

new Regex(@"/archive/\d{4}/\d{2}/\d{2}/(?<postId>\d+)\.aspx$",

        RegexOptions.IgnoreCase | RegexOptions.Compiled);

 

    private int GetPostId(string url)

    {

        Match match = DOTTEXT.Match(url);

        if (match.Groups.Count > 0)

        {

            int postId;

            if (int.TryParse(match.Groups["postId"].ToString(), out postId))

            {

                return postId;

            }

        }

        return 0;

    }

   

    // Retrieve a list of old posts, cache the result

    protected System.Collections.Generic.Dictionary<int, string> GetPosts()

    {

        System.Collections.Generic.Dictionary<int, string> posts =

HttpContext.Current.Cache["posts"] as

            System.Collections.Generic.Dictionary<int, string>;

        if (posts != null) return posts;

       

        posts = new System.Collections.Generic.Dictionary<int, string>();

 

        string query =

"SELECT PostID, DottextPostID FROM be_Posts WHERE DottextPostID IS NOT NULL";

       

        System.Data.SqlClient.SqlDataAdapter sqlDa =

            new System.Data.SqlClient.SqlDataAdapter(query,

            ConfigurationManager.ConnectionStrings["BlogEngine"].ConnectionString);

 

        System.Data.DataTable postTable = new System.Data.DataTable();

        sqlDa.Fill(postTable);

        foreach (System.Data.DataRow item in postTable.Rows)

        {

            Post p = Post.GetPost((Guid)item["PostID"]);

            posts.Add(int.Parse(item["DottextPostID"].ToString()), p.RelativeLink);

        }

 

        HttpContext.Current.Cache.Add("posts", posts, null, DateTime.MaxValue,

Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);

        return posts;

    }

It may not be the most well-designed code, but it does the trick.

Currently rated 3.1 by 9 people

  • Currently 3.111111/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen | Modified by Mooglegiant