Opera 9+ don’t show the session restore window

July 28th, 2011

To set up Opera so that crash-recovery and splash screens are disabled you can do the following:

On Opera, type opera:config in the url bar to edit configuration.
Modify the configuration:
Recovery Strategy = 0
and
Uncheck Show Problem Dialog

FireFox 2.x don’t show the session restore window

July 25th, 2011

When FireFox 2.x came out it was the first version that introduced session restore if the browser crashed (or was shut down hard/incorrectly).

This can be turned off by going into “about:config” finding the key “browser.sessionstore.resume_session” and setting this to false

Also you probably want to check out the startup options under “Tools->Options->When Firefox starts

(This can also be used to show the session restore window by setting the “browser.sessionstore.resume_session” to true)

Note: This can also be used with Flock versions 2.6.x as that is based on FireFox

PHP raw POST data

July 22nd, 2011

To read the raw data being posted to a php page (for instance when $_POST is empty due to problems with encoding types or $HTTP_RAW_POST_DATA not being readable due to php.ini settings) reading file_get_contents is a nice solution.

$postData = file_get_contents('php://input');

PHPMailer send mail in UTF-8 encoding

July 4th, 2011

PHPMailer does not seem to auto-detect encodings, so if you wish to send mail in (for instance UTF-8) you need to tell PHPMailer this. Thankully that is very easy

$phpMailerObject->CharSet = 'UTF-8';

Adding htmlattributes to a ActionLink

May 7th, 2011

To add htmlattributes to a ActionLink might be needed for instance for the layout of the page.

@Html.ActionLink("Link text", "action", "Controller", null, new {style="float:left"})
//Adding a css class (need the @sign as class is a keyword for the compiler). It is also possible to use a Capitol C in Class but then it fails some validations.
@Html.ActionLink("Link text", "action", "Controller", null, new {@class="myCssClassName"})
 
//the syntax for the Html.ActionLink (used in this example is)
public static MvcHtmlString ActionLink(
	string linkText,
	string actionName,
	string controllerName,
	RouteValueDictionary routeValues,
	IDictionary<string, Object> htmlAttributes
)

C# MVC# create a URI from a Url.Action

April 30th, 2011

Sometimes the need arises to create a URI object instead of just a link. This can be done by using Url.Action.

new Uri(Url.Action("action", "controller", null, Request.Url.Scheme))
 
//definitions 
public Uri(
	string uriString
)
 
public string Action(
	string actionName,
	string controllerName,
	Object routeValues,
	string protocol
)

Specifying what area an ActionLink should use

April 30th, 2011

Using routevalues you can tell the html helper what area you want to create a action link to.

//create a link that will go to AreaName
Html.ActionLink("Link Text", "ActionName", "ControllerName", new { Area = "AreaName" }, new{})
//Default area (= no area)
Html.ActionLink("Link Text", "ActionName", "ControllerName", new { Area = "" }, new{})
 
//create a link that will go to AreaName and with some htmlAttributes
Html.ActionLink("Link Text", "ActionName", "ControllerName", new { Area = "AreaName" }, new{@class="myCssClass"})
 
 
//Definition
public static MvcHtmlString ActionLink(
	string linkText,
	string actionName,
	string controllerName,
	RouteValueDictionary routeValues,
	IDictionary<string, Object> htmlAttributes
)

asp.net C# Url.Action with routevalues

April 30th, 2011

Using routevales you can change area and/or pass parameters on to the link you wish to hit.

//"normal" Url.Action - creates a link in the area where it is called from (and don't pass any values along)
<a href="@Url.Action("action", "controller")" class="myCssClass">link text</a>
//Url.Action with a that links to another area (area name or empty for the default area); also sets the category to shoes and it passes along the id that this view has.
<a href="@Url.Action("action", "controller", new { Area = "", id = Model.id, category="shoes"})" class="myCssClass">link text</a>

C# Url encoding/Decoding using the HttpUtility

April 30th, 2011

When there is need to encode/decode a url then the HttpUtility has a function that does this for us.

HttpUtility.UrlDecode(url)
HttpUtility.UrlEncode(url)

Sending ctrl+alt+del through remote desktop

April 30th, 2011

To send the ctrl+alt+del keystrokes when in a remote desktop you press ctrl+alt+end.