About the author

Morten Krogh-Jespersen is the founder of dotnamics - an IT company that develop products and consults in the programming field.

Nokia and WP7: Why the next smartphone from Nokia will be Windows Phone 7 powered

by Morten Krogh-Jespersen 20. august 2010 14:52

First, this is my own guesswork, so if you were to bet money on this, it’s your own responsibility. But, I will try to give some valid points to why, the next Nokia smartphone will be powered by Windows Phone 7.

Ok, so if you were the creator of a brand new mobile phone operating system, and you were late in the game, what would you do to launch your new platform. iPhone is big, Android is big, Windows Phone 7 is nothing right now, but has a great potential. If I were CEO of Microsoft, I would call CEO of Nokia (Olli-Pekka Kallasvuo), the worlds biggest mobile handset company in the world, with “failures” in all their smartphones, with a proposal.

Nokia would be a game changer. So many people around the world trust that brand, so I would do everything that it would take. Apple makes profit on their phones by sale and by iTunes and Apps, Nokia, expert in manufacturing handset, and Microsoft, experts in software, could split the revenue in two. They are both so late in the game, that it would make the most sense.

Microsoft also wants to promote its Bing service, so the more that Microsoft can generate of mobile search on Bing, the more money it will make on advertising.  The sale of hardware is already outsourced by Microsoft to other companies, so why would Nokia not be one of them?

Nokia sees itself as a giant player, because it is a giant player. But who will make contracts with label records, app-developers, news-services etc., when you don’t have a smartphone that people want to buy, on an operating system not supported by many. Search, apps, games, music, office, all of that could be provided by Microsoft, and Nokia has proven they are incapable of delivering this service on its platform. Microsoft is far more able to make deals because they can include 90 % of all PC’s in the world in their potential customers.

Microsoft and Nokia has announced, that they will try to port Microsoft to Symbian Devices. Do I think Microsoft will throw services in the hands of Nokia, when they have a competing product to be released soon? NO – I do not think so.

I am probably wrong :)

Tags: , , ,

Smartphone | Windows phone 7

SEO-friendly HTTP module

by Morten Krogh-Jespersen 19. juli 2010 04:08

There’s a lot that you can do, to make your site more easy to discover by search-engines. One method is normalizing your URI’s, which can be done in different ways. There’s also a difference between ASP.NET Web Forms and MVC, in the way URI’s are handled and expressed.

As you probably know, Google and other search-engines punish duplicate content – and a single '/' is enough to confuse even Google. Therefore I follow some simple rules.

I’ve create a SEO-friendly HTTP module, that helps me do the following:

  • If the request-URI ends with ‘/’ then remove this from the request (for web forms, this should be the other way around)
  • Lowercase all URI’s
  • Check for default routing (‘/index’) – if this is the request, remove '/index' from the uri (for ASP.NET Web forms, this should be, if URI ends with ‘/’, then append ‘default.aspx’.
  • Check for www. this is a personal preference. Just choose one.

Instead of redirecting when we first find a problem, I append all changes to the URI, so that users (and bots) only receive one 301 Redirect.

Below is the httpmodule code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Text.RegularExpressions;

namespace dotnamics_mvc.HttpModules
{
    public class SeoFriendlyHttpModule : IHttpModule
    {
        public void Dispose()
        {
        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }

        void context_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;

            string url = (app.Request.Url.Scheme + "://" + app.Request.Url.Authority + app.Request.Url.AbsolutePath);
            bool redirect = false;

            // check for trailing /
            if (url.EndsWith("/") && app.Request.Url.AbsolutePath != "/")
            {
                redirect = true;
                url = url.Substring(0, url.Length - 1);
            }

            // check for capital letters
            if (Regex.IsMatch(url, @"[A-Z]"))
            {
                redirect = true;
                url = url.ToLower();
            }

            // check for default routing (Index)
            if (url.EndsWith("/index"))
            {
                redirect = true;
                url = url.Substring(0, url.Length - 6);
            }

            // check for www
            if (url.Contains("www."))
            {
                redirect = true;
                url = url.Replace("www.", "");
            }

            if (redirect)
                Redirect301(app, url + app.Request.Url.Query);
        }

        private void Redirect301(HttpApplication app, string location)
        {
            // set status to 301 - Perm Redirect
            app.Response.StatusCode = 301;
            app.Response.Status = "301 Moved Permanently";
            app.Response.StatusDescription = "Moved Permanently";
            app.Response.AddHeader("Location", location);
            app.Response.End();
        }
    }
}

Tags: , , ,

ASP.NET | ASP.NET MVC | SEO | HttpModule

Dynamic data/controller in a masterpage in an ASP.NET MVC website

by Morten Krogh-Jespersen 13. juli 2010 03:28

A lot of web pages provide dynamic data on every page, this could for instance be an advertisement or a funny joke.

On the dotnamics website, there's a dynamic header on every page (except blog pages), which displays a customer reference, a product reference and so on.

I've seen some posts on how to do it, but almost everybody suggest building a base controller - BUT I don't like that idea. Building a base controller might be a good idea, but I think a controller should be encapsulated, and only solve the problem at hand. If you put to much information in a base-controller, you remove the purpose of the controller, imho.

I used the RenderAction html helper to solve the problem.

1: Create a controller, I called mine MasterPageController:

namespace dotnamics2010.Controllers
{
    public class MasterPageController : Controller
    {
        public ActionResult HeaderContent()
        {
            Models.ViewModels.MasterPage.HeaderContent headerContent = new Models.ViewModels.MasterPage.HeaderContent();
            headerContent.InPlaceShuffle();
            return View(headerContent);
        }
    }
}

What this does is, it calls a viewmodel, that generates different headers. I then shuffle the items, before i send the data to the view.

2: add a View:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dotnamics2010.Models.ViewModels.MasterPage.HeaderContent>" %>

<div id="headercontent">
    <div class="items">
        <%
            foreach (dotnamics2010.Models.ViewModels.MasterPage.IHeaderContent content in Model)
            {
                %>
                    <div>
                        <% Html.RenderPartial(content.GetType().Name, content); %>
                    </div>
                <%
            }
            %>
    </div>
 </div>

3: Finally, include in masterpage like this:

                <div id="header_content">
                    <% Html.RenderAction("HeaderContent", "MasterPage"); %>
                </div>

I think this is the perfect solution.

Tags: , ,

ASP.NET | ASP.NET MVC | Masterpage

Convert color in PDF - to print on a printer with no black

by Morten Krogh-Jespersen 4. maj 2010 07:37

Do you know the problem of having no more black ink in your printer - and a PDF document containing tickets or something else and in need of it printed?

This is a nice little hack - but you will need Photoshop.

1) Open the PDF in Photoshop - If 72 dpi is not enough you can change this to 300

2) Choose Image -> Mode -> Grayscale - Say Yes to discard color information

3) Choose Image -> Mode -> Duotone -> Click the color icon and choose the color that fits your remaining printer ink.

 

 

4) Now just print it or save it.

 

Hope this will save you from trouble at some point.

Tags: ,

Nice 2 now | PDF

Dislike a website - say WTF like WTFCNN.com

by Morten Krogh-Jespersen 29. april 2010 08:02

 

WTFCNN.com

What do you do if you dislike a site - disagrees with its point of view or something else. Say WTF.

Some people disagrees with the content that CNN provides on their front page - and to show their unhappiness they have created a site that shows CNN's front page at the top and another news site at the bottom.

I think this is a great idea. With all the facebook groups, twitter and so on, people make a lot of "statements" but they come kind-a cheep. THIS is statement that takes some effort.

I am for sure going to check out the authors of the web-page website http://breadpig.com/ to find out what else they are cooking.

You can find WTFCNN here: http://wtfcnn.com

Tags: ,

Web culture

BlogEngine.net as a web-application

by Morten Krogh-Jespersen 28. april 2010 07:09

In my last post I showed how to run BlogEngine.Net in a sub-folder on web-host. Web-hosts normally put a lot of websites on the same machines so to minimize cost. The thing is, the more websites the less power for you website. It might even be that your host only have on ASP.NET application pool per machine - or they recycle it often.

I might be wrong - but I have experienced websites that need to recompile on each ASP.NET worker process recycle - so it might be that your website is not only running with half the power - but also experience a more frequently recompilations. 

The only solutions is to make a a web-application (precompiled) web-site. That way ASP.NET only needs to transform the MSIL code to machine code - you can find more information here: http://msdn.microsoft.com/en-us/library/bb398860.aspx

Pro's with a precompiled BlogEngine.net

  • Faster response-time - good for users and SEO
Con's with a precompiled BlogEngine.net
  • Wikis and Extensions are no longer dynamic - you cannot add extensions on the fly

If you need to add extensions on the fly - and you don't have Visual Studio to perform the precompilation then you should stick with the web-version of BlogEngine.net

If not I strongly suggest that you put in the effort. BenAmada has written how to it here: http://blogengine.codeplex.com/Thread/View.aspx?ThreadId=43154

I'm personally the lazy type - and if you are too then you can save yourself some work by download the file attached to this post. Remember, this is a version with BlogEngine.NET running in a sub-folder.

dotnamics_blogengine.rar (2.05 mb)

Tags:

BlogEngine.net

How to install BlogEngine.net in a subfolder on a web host

by Morten Krogh-Jespersen 27. april 2010 08:12

This is my first entry on this blog - so why not kick it off with some information about how I got this blog engine (which name is BlogEngine.NET) running.

I have a danish web host provider called unoeuro.com that does not give me an option to create virtual directories in their webmanager. I guess a lot of people have that problem. I was unable to use a PHP hotel due to some webservices in my domain, and a sub-domain would not be sufficient due to SEO optimizing.

(UnoEuro.com are actually willing to create virtual directories - but that would not be any fun)

If we are unable to create virtual directories, the ASP.NET worker process will execute the files under the root - and see the whole as a large website with just one place of configuration. This means that we need to copy some of the most important files into the root of the website.

So here is what you do for version BlogEngine.Net 1.6.0:

1) Pick a sub-folder name. I chose "mortens-blog" because my name is Morten and it is a weblog

2) Unzip all files of the (web) release into this folder

3) Move the following files into the root:

  • App_Code folder
  • App_GlobalResources folder
  • bin folder
  • Global.asax
  • Web.Config
  • COPY pics
4) Rename "App_Data" to "data" in your sub-folder that I call mortens-blog

5) Modify web.config and change the following lines:
  • <add key="BlogEngine.VirtualPath" value="~/{sub-folder name}/" />
  • <forms timeout="129600" name=".AUXBLOGENGINE" protection="All" slidingExpiration="true" loginUrl="~/{sub-folder name}/login.aspx" defaultUrl="http://{your domain}/{sub-folder name}" cookieless="UseCookies"/>
  • <customErrors mode="On" defaultRedirect="~/{sub-folder name}/error404.aspx">
  • <error statusCode="404" redirect="~/{sub-folder name}/error404.aspx"/>
  • <add name="SecuritySiteMap" description="Used for authenticated users." type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" securityTrimmingEnabled="true" siteMapFile="~/{sub-folder name}/Web.sitemap"/>

6) Your almost there - now the only thing missing is the sitemap located here: ~/{sub-folder name}/Web.sitemap

That is basically it.

BUT WAIT - there might be some references to masterpages, usercontrols etc. that may not work.

That is why i have created a .rar file that you can download. The only thing you have to do if you use this file is:

1) Change the folder "mortens-blog" to your preferred name

2) Search and replace "mortens-blog" with your preferred name in the root web.config

3) Search and replace "mortens-blog" with your preferred name in the ~/{sub-folder name}/Web.sitemap

You could also wait for the next post were I will modify the website to a web-application. If you are planning on hosting your blog on a popular web host you might benefit a bit by choosing the web-application.

BlogEngine.NET.rar (1.42 mb)

Tags:

BlogEngine.net