0 Comments

I have set a theme for this webform project in the web.config file and also a masterpagefile

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <pages  theme="themeName" masterPageFile="~/mp1.master" />
    </system.web>
</configuration>

Unfortunatly this did not work. I have spend a long time searching why my application kept showing the old masterpagefile. I believe that it had to do with this checkbox:

snip_20161027144613

When you publish your webform application and click on configure, you should set the checkbox near the ‘allow precompiled site to be updatable’.

Otherwise it seems that during the compilation, it will bake in the configured masterpage file in your *.aspx files.

Please let me know if I am wrong, but this did fix it for me.

 

Good luck!

Pin on pinterest Plus on Googleplus Post on LinkedIn

So my Surface pro 3 running the anniversary update and latest updates got hot. So hot that I got the white thermometer of death.

I borrowed this picture from this topic on Microsoft Community. I could not take my own picture, because I was too upset.

So I contacted the store where I bought the device and there has been a change with the return policy in the Netherlands. So I could not send it in for repair at the store. I had to contact Microsoft myself. After logging in with my Microsoft account I could register the issue without any issues. Microsoft mailed me an UPS label for the box and within a few days I got a mail with a trackingcode that a similar device was heading my way.

My SP3 was over 1,5 year old and like a lot of overheating sp3’s equiped with an i7 cpu.

Windows Store

Having a lot of applications in the store, made it easy for me to get back to work fast. Open live writer is now a store app too so that is nice! The only applications I had to download outside the store were:

  • Visual Studio
  • FileZilla
  • Skype (I know there is a preview uwp app in the anniversary update…)
  • Sql Server Management Studio
  • Office 365
  • Notepad++
  • Adobe cloud (and Photoshop)
  • Chrome
  • Firefox (and mozbackup)
  • Github for Windows
  • TeamViewer
  • Snip (office mix)

 

It would save me even more time if those were in the store. And if Visual Studio had some kind of installed extension restore option.

So I was supprised how fast and good the service for the surface is and how fast people can get back to work with all the latest software on Windows 10. Could be even faster if I would do a system restore. But I wanted a clean install with all the legacy sql, mvc, azure installers etc. Maybe it will be even faster in the future with using chocolatey or oneget and restore settings stored in the cloud (onedrive)

 

I hope this will cheer up people who have Surface heating issues. I was only a week without the surface.

Good luck!

Pin on pinterest Plus on Googleplus Post on LinkedIn
0 Comments

Microsoft SQL Server has the ability to format the query output to xml, which is great. I used version “Microsoft SQL Server 2008 (SP3) - 10.0.5500.0 (X64)” to output XML to have a nested data structure, but there is unfortunately no first citizen support for JSON which is big on the web these days. Perhaps it is left out on purpose to make sure that people are unable to direct output their data as JSON and are forced to build a layer in between so that it can also authenticate and add security to a request. Web API is great for this. But back to the subject: I wanted to output my nested data as JSON really quickly with the minimum amount of code.

In a nutshell, I got the data as xml and converted that to JSON and send it to the output of a generic handler (*.ashx)

Here is my source code for my easy SQL2JSON solution:

private XDocument GetProducts(string q)
{
    SqlCommand comProd = new SqlCommand(@"SELECT ProductCode, ProductEan13, CategoryName FROM PRODUCTS 
        inner join CATEGORIES on products.CategoryID = CATEGORIES.CategoryID
        WHERE ((FactoryCode LIKE @name) OR (ProductCode LIKE @name)) AND (ProductDeleted = 0) for xml raw ('Product'), ROOT ('Products');");
    comProd.Parameters.AddWithValue("name", q + "%");
    string xml = SsDb.GetScalar(comProd).ToString();
    return XDocument.Parse(xml);
}

This gave me an `XDocument` object which I still have to convert to JSON

Since I was using an generic handler I retrieved the search parameter from the query string and used it as input parameter for the `GetProducts` method.

public void ProcessRequest(HttpContext context)
{
    context.Response.ContentType = "application/json";
    context.Response.Cache.SetCacheability(HttpCacheability.Public);
    context.Response.Cache.SetExpires(DateTime.Now.AddDays(1));
    context.Response.Cache.SetMaxAge(new TimeSpan(24, 0, 0));

    string q = context.Request.QueryString.Get("q");
    context.Response.Write(JsonConvert.SerializeXNode(GetProducts(q)));
}

So the most important line is the last one:

context.Response.Write(JsonConvert.SerializeXNode(GetProducts(q)));

Do not forget to use the one-nuget-package-that-rules-them-all (Install-Package Newtonsoft.Json )

using Newtonsoft.Json;

 

Now you can access your JSON data source with the C# generic handler from your JavaScript

yourHandler.ashx?q=yourproductcode

I hope this has been of any help. good luck!

Pin on pinterest Plus on Googleplus Post on LinkedIn
0 Comments

Mads Kristensen created BlogEngine.Net back in 2007. I have tested Dasblog, Wordpress and imageBlogEngine.Net and decided back in 2010 that BlogEngine was my blogging platform of choice. But now in 2014 when responsive design, JSON, HTML5, CSS3 is all well known and supported. I decided to migrate to a new and minimalistic blog platform. It is called MiniBlog and hosted on GitHub. I really like the project’s name and goal. It has less overhead and is really fast! It is based on bootstrap, so responsive by default.

So the requirements for me for my new blogging platform is:

  • .Net C#
  • Bootstrap theme(s)
  • Lightweight
  • Fast
  • Live writer integration
  • RSS feeds (to feed to feedburner)
  • SEO friendly
  • Mobile friendly
  • Azure hosting support

Miniblog has it all. Because I am a lazy bastard programmer, I will call BlogEngine.Net BE and Miniblog MB. Here is how I moved from BE to MB:

1. Forked MB

So that I can contribute and give back to the community. And I can keep my own branch and have a local repository.

2. Moved App_Data posts

Copied all posts from BE to MB. But MB could not found my categories.

3. Formatted BE data for MB

Cloned this formatter to my desktop and uncommented line 17 and commented out line 18 of program.cs and renamed the folder parameter to origin in order to get it to run.

4. Made a custom theme

I have just copied one of the existing theme’s and made adjustments to the CSS (and razor view) You really have all freedom with this blogging platform

5. Moved login credentials

The default login is demo, demo and is stored in your web.config. You can change it, but perhaps accidentally commit it to GitHub, so follow this guide to move it to a separate authentication.config and exclude it in your gitignore.

6. Google Analytics

A plain installation of MiniBlog does not include Google Analytics “integration”. So you manually have to add the tracking code in your custom theme (from step 4) It is a good time to move your old Analytics to the new “universal analytics”. Add the snippet before your </head> tag.

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-XXXXXXX-X');
ga('send', 'pageview');

7. Syntax highlighter

To make the code snippets more readable I use this javascript library to enable syntax highlighting. At first, I took the wrong javascript files from the zip. I found the solution on this post about xregexp not defined.

8. Custom pages

MB is by default just a blogging platform and does not have custom pages for about and/or contact. It is better to add them in the view folder, but then you might have to do some work for better routing, so I added an about.cshtml and contact.cshtml to the root of the project. You can reference the theme’s shared layout there to make it match the rest of the sites layout.

9. Social sharing

This is also related to point 4. It gives visitors the option to share your posts on social networks which can give you a better reach. You can use AddThis or something similar. Or use the official plugins from Facebook and Twitter but that includes more javascript and dom manipulations which cause more load on server and client side. Which gives you less points with Google’s Pagespeed. So I combined the url’s from Hanselman’s post and the icons from Flaticon with the “embed resource as base64” option from web essentials Visual Studio extension.

10. Ads

I included a small javascript reference from developer media (previously lake quincy media) to add some ads to the posts (to try to earn back the money for my hosting bill) and included it in my theme, but I am still looking for the best performing ad dimensions.

11. Url-rewrite

I am using this free extension of IIS to rewrite some url’s and have added this rule to include the www subdomain:

<rule name="Add WWW prefix" stopProcessing="true">
  <match url="(.*)" ignoreCase="true" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="^jphellemons\.nl$" />
  </conditions>
  <action type="Redirect" url="http://www.jphellemons.nl/{R:0}" redirectType="Permanent" />
</rule>
MB has default rules to remove the www subdomain (which I disabled) and has a rule to remove the .aspx which BE has, to get cleaner url’s


Have I missed something? What changes did you make when moving to MiniBlog?

Pin on pinterest Plus on Googleplus Post on LinkedIn
0 Comments

but COM was not at home, so COM could not answer ;)we_not_alone_02

This was my error (it was actually a warning according to Visual Studio 2013):

Warning 13 Generation of the designer file for MagazineDetails.aspx failed: Error HRESULT E_FAIL has been returned from a call to a COM component. C:\www\myproject\MagazineDetails.aspx

It is the same error as the following people have/had:

I am not alone, so I decided to blog about it. My configuration contains a Windows 8.1 x64 install with all the latest updates and have Visual Studio 2013 (version 12.0.21005.1) and I had this issue with just one aspx file.

The error was not even visible at first. I had to lower the warning level (it was 4, and error was visible at 3)

project-settings

The thing is that this invisible error broke my intellisense and when I added controls like literals, buttons, labels etc. to the aspx. The “codebehind” (aspx.cs) did not recognize them. It was frustrating! And this was only an issue with one or two aspx files. (out of 30 or something)

On stackoverflow there were three rather nice suggestions:

  • (re-)convert to web application the project
  • switch to the designer and back to re-generate
  • restart visual studio

Unfortunately, none of the above fixed my problem. I found an other suggestion and cannot find the source, so I am sorry that I can not give credits to the person who pointed me in the right direction. But the solution is to add a classname to the page directive. Somehow it caused the IDE to recognize all the controls in the code behind and re-enabled the intellisense in the code behind.

<%@ Page Title="Magazine details" Language="C#" MasterPageFile="~/nl.Master" AutoEventWireup="true" CodeBehind="MagazineDetails.aspx.cs" Inherits="NikkiLissoni.MagazineDetails" ClassName="NikkiLissoni.MagazineDetails" %>

I hope this will help out other developers and might save them an hour or two searching for a solution for this strange behaviour.

Good luck!

kick it on DotNetKicks.com Shout it

Pin on pinterest Plus on Googleplus Post on LinkedIn