Thursday, May 23, 2013

AltGr button stops to work (fix)


From time to time my AltGr button stops to work. This is very annoying when trying to type certain special characters. There might be several reasons for this probably, but in my case the culprit is usually Remote Desktop.

If this happens and you have Remote Desktop running (in background too), simply quit Remote Desktop to get AltGr working again.

I had this problem before without running Remote Desktop, and then it was the NVIDIA control panel who had assigned AltGr+(number keys) as global shortcuts. Disable the shortcuts to get it working.

Wednesday, April 3, 2013

Mix of character encoding on a web page

I recently experienced a weird error with encoding while working on an Umbraco site. The page would show some special chars correct and some not. The pattern was that chars in the template would display wrong, but chars in the (dynamic) content would display correct.

First step was to verify that everything was UTF-8; the HTML header, the template (html) files, the (html) partial files etc. Then check that all config settings were set to UTF-8; web.config and umbracoSettings.config.

Still didn't work. I also tried manually switching encoding in chrome (tools->encoding) but it still didn't work.

The fix:
I needed to add the fileEncoding attribute to the globalization tag in web.config

before:
<globalization requestEncoding="UTF-8" responseEncoding="UTF-8" />

after:

<globalization requestEncoding="UTF-8" responseEncoding="UTF-8" 
fileEncoding="UTF-8" />


Ah, well...

Monday, February 4, 2013

Getting Umbraco 6 to play nicely with Visual Studio

When developing Umbraco 6 thru Visual Studio (in my case VS2012) it (VS) was not playing nicely.

My main issue was that intellisense and even compilation didn't work for SurfaceControllers. Compilation would succeed every time not giving me errors until run-time.

The issue is that Visual Studio thought this was a Web Forms project (wich Umbraco is), but I was working with MVC. I found the solution in this blog post by Colin Angus MacKay at the bottom.

Solution:

To do this, you need to right click on the web project and click “Unload Project”, when it has unloaded, right-click again and click “Edit xxx.csproj”.
Look for the element named “ProjectTypeGuids” and add in the guid:
{E3E379DF-F4C6-4180-9B81-6769533ABE47}

Separate the GUIDs with semi-colon. Then reload the project.

The project is the main Umbraco project (in case you have more than one). You will have to re-set the project as Start-up project after this.

Update: It seems to be a little unstable, as VS suddenly reverted to old (bad) behaviour. Unloading then reloading project fixed it, but hopefully there is a better solution. Will update if I find one.

Note: Umbraco 6 already ships with MVC 4 and has built in support for Controllers (called SurfaceControllers) so the rest of Colin's blog entry is not necessary for Umbraco 6.

Update: When retrying this I found that I had to put the new GUID first in the list. The project refused to load when I put the GUID at the end.

Thursday, July 5, 2012

Get dotlesscss to show compile errors

If the compile of a .less file fails with dotlesscss it will often just show a blank page. To make it show the compile error, just add a logger to the config (see answer by tony722).

This settings worked for me:


<dotless minifyCss="false" cache="false" web="false" logger="dotless.Core.Loggers.AspResponseLogger" />

See list of options here.

Friday, June 29, 2012

.less files gives 404 or 406 error on IIS

A quick reminder to myself if I ever run into this problem:  When using .less as css it might work fine when running thru Visual Studio but it fails with a 404 or a 406 when deploying to the IIS server. (ie. the CSS is not applied to the web page).

Probable solutions are here (404 - need to specify mime type) and here (406 - need to have consistent types).

Also should have IIS in Integrated Mode, not Classic if possible. Found this tip here

Monday, June 11, 2012

Problems installing ASP.NET MVC3

I recently installed the CMS Umbraco 5, but I had problems getting it to run because I didn't have MVC3 installed. When I used Web Platform Installer to install it - it didn't work (I think there was no error message even) - after installing MVC3 the files where nowhere to be found.

The error you'll receive is (when running Umbraco): Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

The reason MVC3 won't install is because I had a newer version of NuGet installed (v1.5). The installer produces a fatal error when it finds a newer (than 1.2) version instead of continuing. The semi-official fix from Microsoft is to uninstall Nuget, install MVC then reinstall Nuget.

There is also another workaround, to manually run the installation files after the installer has extracted them (start installation, when it fails find the extracted installation files in the Temp folder and copy them somewhere else. Then install them manually after finishing the first install).

Note that the problem is actually in the 'MVC3 Tools' package, so for me it worked to simply install the binaries (since I'm just going to run Umbraco, not develop MVC3 apps I don't need the tools).

Download just the runtime from here: http://www.microsoft.com/en-us/download/details.aspx?id=4211

The tools are here (in case you need them): http://www.microsoft.com/en-us/download/details.aspx?id=1491

Tuesday, June 5, 2012

ASP.NET MVC 4 and mobile web

Here is how to set up for mobile web on MVC 4 (or at least my preferred way) follow instructions here:

Note the comment from Chip below the article, there is a Last-In-First-Out principle for the order of specifying the order of devices. So instead of the order used in the article, use Chip's.

Also note that the examples are for MVC 4 developer preview, the correct way in MVC 4 beta is 
  • DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("mobile")
instead of
  • DisplayModes.Modes.Insert(0, new DefaultDisplayMode("mobile")


So updating and combining the info, this is the correct way in global.asax:



DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("mobile") {
          ContextCondition = Context => Context.Request.Browser.IsMobileDevice
});


DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Tablet"){
          ContextCondition = Context => [how to id tablet]

});

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("AndroidTablet"){
         ContextCondition = Context => [how to id android tablet]

});


)