<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Chief of the System Blog</title>
	
	<link>http://remy.supertext.ch</link>
	<description>We should be taught not to wait for inspiration to start a thing. Action always generates inspiration. Inspiration seldom generates action.</description>
	<lastBuildDate>Fri, 03 Feb 2012 12:45:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ChiefOfTheSystemBlog" /><feedburner:info uri="chiefofthesystemblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Basic Authentication with WCF Web API Preview 6</title>
		<link>http://feedproxy.google.com/~r/ChiefOfTheSystemBlog/~3/yNMXAlId9Lw/</link>
		<comments>http://remy.supertext.ch/2012/02/basic-authentication-with-wcf-web-api-preview-6/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 12:35:27 +0000</pubDate>
		<dc:creator>Rémy Blättler</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[Authorization]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[wcf]]></category>
		<category><![CDATA[wcf web api]]></category>

		<guid isPermaLink="false">http://remy.supertext.ch/?p=329</guid>
		<description><![CDATA[One should not believe it, but it seems that there is no official way to use your own version of Basic HTTP Authentication with the WCF Web API in an MVC Web Application yet. So, now that I’ve used all &#8230; <a href="http://remy.supertext.ch/2012/02/basic-authentication-with-wcf-web-api-preview-6/">[weiterlesen]</a>]]></description>
			<content:encoded><![CDATA[<div class="google_plus_one"><g:plusone size="standard" count="false" url="http://remy.supertext.ch/2012/02/basic-authentication-with-wcf-web-api-preview-6/"></g:plusone></div><p>One should not believe it, but it seems that there is no official way to use your own version of Basic HTTP Authentication with the WCF Web API in an MVC Web Application yet. So, now that I’ve used all possible necessary keywords we can dive right in.</p>
<p>&#160;</p>
<p>We are using a custom ASP.NET Membership provider and the REST API should work with a token over Basic HTTP Authentication (like Basecamp). So, the built in Windows Basic Authentication is not an option.</p>
<p>After scanning dozens of posts on Stackoverflow and other resources I realized that either I have to go with the WCF REST Contrib library or with Open Rasta. But since I already started with the WCF Web API Preview 6 to build my REST API (and it worked fine so far) I didn’t want to switch now.</p>
<p>The most promising solution I found was from <a href="http://cacheandquery.com/blog/2011/03/customizing-asp-net-mvc-basic-authentication/">jslaybaugh</a>. He is basically using a custom version of the [Authorize] attribute from the normal MVC framework and somehow integrated it all with Ninject. For some reason I didn’t got it working. In general AuthorizeAttribute and action filters are MVC specific. For WCF we have the HttpOperationHandler or the DelegatingHandler. They have their specific uses and advantages. Some info about his from <a href="http://codebetter.com/glennblock/2011/05/17/message-handlers-vs-operation-handlers-which-one-to-use-2/">Glenn Block</a>.</p>
<p>I’ve decided to go with the HttpOperationHandler and found a good example from Phil Haack where he implements a <a href="http://haacked.com/archive/2011/10/19/implementing-an-authorization-attribute-for-wcf-web-api.aspx">Role authorization Module</a>, that also works with Attributes, so we can implement something very similar to the AuthorizeAttribute of MVC. There are simpler solutions, e.g. you could just check this inside your Controller, but <a href="http://blogs.teamb.com/craigstuntz/2009/09/09/38390/">Craig Stuntz</a> has some good points about why this is a bad idea.</p>
<p>So, let’s look at the code (which is a potpourri of all the above examples):</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>AttributeUsage<span style="color: #008000;">&#40;</span>AttributeTargets<span style="color: #008000;">.</span><span style="color: #0000FF;">Method</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> BasicHttpAuthorizationAttribute <span style="color: #008000;">:</span> Attribute
<span style="color: #008000;">&#123;</span>
    <span style="color: #6666cc; font-weight: bold;">bool</span> requireSsl <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> RequireSsl
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> requireSsl<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        set <span style="color: #008000;">&#123;</span> requireSsl <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>With this simple BasicHttpAuthorizationAttribute class we can achieve the the attribute functionality. So we can use it like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>BasicHttpAuthorization<span style="color: #008000;">&#40;</span>RequireSsl <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #008000;">&#91;</span>WebGet<span style="color: #008000;">&#40;</span>UriTemplate <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> IEnumerable<span style="color: #008000;">&lt;</span>exampleobject<span style="color: #008000;">&gt;</span> Get<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span></pre></div></div>

<p>&#160;</p>
<p>The RequireSsl is just an example property, you could also do a role membership check in the same way.</p>
<p>But the most important part is the implementation of the HttpOperationHandler. We pass the BasicHttpAuthorizationAttribute as an argument. </p>
<p>There are three main points that deserve attention here:</p>
<ol>
<li>If the user is not authenticated yet or provides the wrong credentials we return a HttpResponseException in the OnHandle method. We set the status code to 401 and add the WWW-Authenticate = Basic header. This creates the functionality, where the browser asks for a username/password and then automatically resends the request. </li>
<li>In ParseAuthHeader we get the username and password out of the request. You can&#160; then use this info with in your own way. For example with your own custom membership provider. </li>
<li>If the user can access this method, we create a GenericPrincipal and assign it to HttpContext.Current.User. Afterwards you can then just use your normal MemberShip and RoleProvider like in every normal ASP.NET application. </li>
</ol>
<p>Other than that, there is not much magic in here.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> BasicHttpAuthorizationOperationHandler <span style="color: #008000;">:</span> HttpOperationHandler<span style="color: #008000;">&lt;</span>httprequestmessage httprequestmessage ,<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&#123;</span>
&nbsp;
    BasicHttpAuthorizationAttribute basicHttpAuthorizationAttribute<span style="color: #008000;">;</span>
&nbsp;
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">public</span> BasicHttpAuthorizationOperationHandler<span style="color: #008000;">&#40;</span>BasicHttpAuthorizationAttribute authorizeAttribute<span style="color: #008000;">&#41;</span>   
        <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;response&quot;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        basicHttpAuthorizationAttribute <span style="color: #008000;">=</span> authorizeAttribute<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> HttpRequestMessage OnHandle<span style="color: #008000;">&#40;</span>HttpRequestMessage input<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>Authenticate<span style="color: #008000;">&#40;</span>input<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> input<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span>
        <span style="color: #008000;">&#123;</span>
            var challengeMessage <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> HttpResponseMessage<span style="color: #008000;">&#40;</span>HttpStatusCode<span style="color: #008000;">.</span><span style="color: #0000FF;">Unauthorized</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            challengeMessage<span style="color: #008000;">.</span><span style="color: #0000FF;">Headers</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;WWW-Authenticate&quot;</span>, <span style="color: #666666;">&quot;Basic&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">throw</span> <span style="color: #008000;">new</span> HttpResponseException<span style="color: #008000;">&#40;</span>challengeMessage<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> Authenticate<span style="color: #008000;">&#40;</span>HttpRequestMessage input<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>basicHttpAuthorizationAttribute<span style="color: #008000;">.</span><span style="color: #0000FF;">RequireSsl</span> <span style="color: #008000;">&amp;&amp;</span> <span style="color: #008000;">!</span>HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsSecureConnection</span> <span style="color: #008000;">&amp;&amp;</span> <span style="color: #008000;">!</span>HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsLocal</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Headers</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AllKeys</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Authorization&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #6666cc; font-weight: bold;">string</span> authHeader <span style="color: #008000;">=</span>  HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Headers</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Authorization&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
        IPrincipal principal<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>TryGetPrincipal<span style="color: #008000;">&#40;</span>authHeader, <span style="color: #0600FF; font-weight: bold;">out</span> principal<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">User</span> <span style="color: #008000;">=</span> principal<span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> TryGetPrincipal<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> authHeader, <span style="color: #0600FF; font-weight: bold;">out</span> IPrincipal principal<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        var creds <span style="color: #008000;">=</span> ParseAuthHeader<span style="color: #008000;">&#40;</span>authHeader<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>creds <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>TryGetPrincipal<span style="color: #008000;">&#40;</span>creds<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span>, creds<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span>, <span style="color: #0600FF; font-weight: bold;">out</span> principal<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        principal <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> ParseAuthHeader<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> authHeader<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// Check this is a Basic Auth header </span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>authHeader <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">||</span> authHeader<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span> <span style="color: #008000;">||</span> <span style="color: #008000;">!</span>authHeader<span style="color: #008000;">.</span><span style="color: #0000FF;">StartsWith</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span>Basic<span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// Pull out the Credentials with are seperated by ':' and Base64 encoded </span>
        <span style="color: #6666cc; font-weight: bold;">string</span> base64Credentials <span style="color: #008000;">=</span> authHeader<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">6</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> credentials <span style="color: #008000;">=</span> Encoding<span style="color: #008000;">.</span><span style="color: #0000FF;">ASCII</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetString</span><span style="color: #008000;">&#40;</span>Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">FromBase64String</span><span style="color: #008000;">&#40;</span>base64Credentials<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Split</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> <span style="color: #6666cc; font-weight: bold;">char</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">':'</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>credentials<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span> <span style="color: #008000;">!=</span> <span style="color: #FF0000;">2</span> <span style="color: #008000;">||</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>credentials<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">||</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>credentials<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// Okay this is the credentials </span>
        <span style="color: #0600FF; font-weight: bold;">return</span> credentials<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">bool</span> TryGetPrincipal<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> userName, <span style="color: #6666cc; font-weight: bold;">string</span> password, <span style="color: #0600FF; font-weight: bold;">out</span> IPrincipal principal<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// this is the method that does the authentication </span>
        <span style="color: #008080; font-style: italic;">// you can replace this with whatever logic you'd use, but proper separation would put the</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>userName<span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;remy@test.ch&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&amp;&amp;</span> password<span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;test&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// once the user is verified, assign it to an IPrincipal with the identity name and applicable roles</span>
            <span style="color: #008080; font-style: italic;">// Example:</span>
            <span style="color: #008080; font-style: italic;">//principal = new GenericPrincipal(new GenericIdentity(userName), System.Web.Security.Roles.GetRolesForUser(userName));</span>
&nbsp;
            principal <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> GenericPrincipal<span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> GenericIdentity<span style="color: #008000;">&#40;</span>userName<span style="color: #008000;">&#41;</span>, <span style="color: #008000;">new</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span><span style="color: #666666;">&quot;Admin&quot;</span>, <span style="color: #666666;">&quot;User&quot;</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span>
        <span style="color: #008000;">&#123;</span>
            principal <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Last but not least, we need to hook up our HttpOperationHandler with the BasicHttpAuthorizationAttribute object and route. For this we create a custom WebApiConfiguration and use a class extension to do the wiring. Honestly, I’m not really sure what is going on here, but it works <img src='http://remy.supertext.ch/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ApiConfiguration <span style="color: #008000;">:</span> WebApiConfiguration
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> ApiConfiguration<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        EnableTestClient <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
&nbsp;
        RequestHandlers <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>c, e, od<span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// TODO: Configure request operation handlers</span>
        <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AppendAuthorizationRequestHandlers</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> ConfigExtensions
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> AppendAuthorizationRequestHandlers<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> WebApiConfiguration config<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        var requestHandlers <span style="color: #008000;">=</span> config<span style="color: #008000;">.</span><span style="color: #0000FF;">RequestHandlers</span><span style="color: #008000;">;</span>
        config<span style="color: #008000;">.</span><span style="color: #0000FF;">RequestHandlers</span> <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>c, e, od<span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>requestHandlers <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                requestHandlers<span style="color: #008000;">&#40;</span>c, e, od<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// Original request handler</span>
            <span style="color: #008000;">&#125;</span>
            var authorizeAttribute <span style="color: #008000;">=</span> od<span style="color: #008000;">.</span><span style="color: #0000FF;">Attributes</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OfType</span><span style="color: #008000;">&lt;</span>basichttpauthorizationattribute<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
              <span style="color: #008000;">.</span><span style="color: #0000FF;">FirstOrDefault</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>authorizeAttribute <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                c<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> BasicHttpAuthorizationOperationHandler<span style="color: #008000;">&#40;</span>authorizeAttribute<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>And we pass this configuration in the global.asax.cs to the route handler:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> RegisterRoutes<span style="color: #008000;">&#40;</span>RouteCollection routes<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    var config <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ApiConfiguration<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    routes<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> ServiceRoute<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;example&quot;</span>, <span style="color: #008000;">new</span> HttpServiceHostFactory<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> Configuration <span style="color: #008000;">=</span> config <span style="color: #008000;">&#125;</span>, <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>ExampleAPI<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>That is it. You can download the example project here: <a href="http://remy.supertext.ch/wp-content/uploads/2012/02/BasicAuthenticationWithWcfWebAPI.zip">BasicAuthenticationWithWcfWebAPI.zip</a></p>
<p>&#160;</p>
<p>Please let me know if this works for you and specially, if you find ways to improve it.</p>
<img src="http://feeds.feedburner.com/~r/ChiefOfTheSystemBlog/~4/yNMXAlId9Lw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://remy.supertext.ch/2012/02/basic-authentication-with-wcf-web-api-preview-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://remy.supertext.ch/2012/02/basic-authentication-with-wcf-web-api-preview-6/</feedburner:origLink></item>
		<item>
		<title>Twitter hashtags for translators</title>
		<link>http://feedproxy.google.com/~r/ChiefOfTheSystemBlog/~3/grW6g5fMYCI/</link>
		<comments>http://remy.supertext.ch/2011/12/twitter-hashtags-for-translators/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 19:09:25 +0000</pubDate>
		<dc:creator>Rémy Blättler</dc:creator>
				<category><![CDATA[Localization]]></category>
		<category><![CDATA[Translation]]></category>
		<category><![CDATA[#G11n]]></category>
		<category><![CDATA[#i18n]]></category>
		<category><![CDATA[#L10n]]></category>
		<category><![CDATA[#T9n]]></category>
		<category><![CDATA[#xl8]]></category>
		<category><![CDATA[#xl8r]]></category>
		<category><![CDATA[hashtags]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://remy.supertext.ch/?p=318</guid>
		<description><![CDATA[#i18n i18n stands for internationalization. i + 18 letters + n Take the first letter, count up to the second last and then the last one. Internationalization describes the process of planning and developing a product (normally software) that can &#8230; <a href="http://remy.supertext.ch/2011/12/twitter-hashtags-for-translators/">[weiterlesen]</a>]]></description>
			<content:encoded><![CDATA[<div class="google_plus_one"><g:plusone size="standard" count="false" url="http://remy.supertext.ch/2011/12/twitter-hashtags-for-translators/"></g:plusone></div><p><strong>#i18n</strong></p>
<p>i18n stands for <strong>internationalization</strong>.</p>
<p>i + 18 letters + n</p>
<p>Take the first letter, count up to the second last and then the last one.</p>
<p>Internationalization describes the process of planning and developing a product (normally software) that can be adapted into different cultures and languages without changing the core architecture of it afterwards.</p>
<p>&nbsp;</p>
<p><strong>#L10n</strong></p>
<p>This is <strong>localization</strong>. Works the same way as #i18n.</p>
<p>Localization is the actual work that needs to be done to make the product support multiple cultures and languages. For example translating a  user interface.</p>
<p>&nbsp;</p>
<p><strong>#T9n</strong></p>
<p>Again, same principle, but this means <strong>translation</strong>.</p>
<p>&nbsp;</p>
<p><strong>#G11n</strong></p>
<p>The last one of this group. Short for <strong>globalization</strong>.</p>
<p>Globalization describes the whole life cycle of a global product. This starts with the design and development until marketing and adaption into different markets.</p>
<p>&nbsp;</p>
<p><strong>#xl8</strong></p>
<p>Stands for translate.</p>
<p>x = trans</p>
<p>l = l</p>
<p>8 = ate</p>
<p>&nbsp;</p>
<p><strong>#xl8r</strong></p>
<p>Similar to #xl8, just instead of translate, it means translator.</p>
<p>x = trans</p>
<p>l = l</p>
<p>8 = ate</p>
<p>r = r</p>
<p>Alternative you could use <strong>#t8r</strong>, but #xl8r is much wider used. At least according to a <a href="https://www.google.com/#sclient=psy-ab&amp;hl=en&amp;safe=off&amp;source=hp&amp;q=%22%23xl8r%22%20translation&amp;pbx=1&amp;oq=&amp;aq=&amp;aqi=&amp;aql=&amp;gs_sm=&amp;gs_upl=&amp;bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&amp;fp=a1bc1589ec616832&amp;biw=1556&amp;bih=922&amp;pf=p&amp;pdl=3000">google search</a>:</p>
<p>&#8220;#xl8r&#8221; translation -&gt;About 1,010,000 results</p>
<p>&#8220;#t8r&#8221; translation -&gt; About 42,400 results</p>
<p>&nbsp;</p>
<p>Instead of the short versions, people also use the normal words, but since you have only 140 chars at your disposal, they are not very common:</p>
<p>#localization</p>
<p>#translation</p>
<p>#language</p>
<p>&nbsp;</p>
<p>I’ve already made a similar post about this topic a while ago:</p>
<p><a href="http://blog.supertext.ch/2010/04/was-bedeuten-l10n-und-i18n/">http://blog.supertext.ch/2010/04/was-bedeuten-l10n-und-i18n/</a></p>
<p>&nbsp;</p>
<p>And Jennifer McNulty wrote another nice explanation here:<br />
<a href="http://blog.adaquest.com/2011/09/23/g11n-i18n-l10n-translation-%E2%80%93-sure-you-know-what-these-mean-or-feeling-gilty-because-you-need-clarification-2/">http://blog.adaquest.com/2011/09/23/g11n-i18n-l10n-translation-%E2%80%93-sure-you-know-what-these-mean-or-feeling-gilty-because-you-need-clarification-2/</a></p>
<p>&nbsp;</p>
<p>You have questions about other tags? Check out <a href="http://tagdef.com">#tagdef</a>.</p>
<img src="http://feeds.feedburner.com/~r/ChiefOfTheSystemBlog/~4/grW6g5fMYCI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://remy.supertext.ch/2011/12/twitter-hashtags-for-translators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://remy.supertext.ch/2011/12/twitter-hashtags-for-translators/</feedburner:origLink></item>
		<item>
		<title>A WPF project running from the CMD Prompt or as a Service and has a GUI</title>
		<link>http://feedproxy.google.com/~r/ChiefOfTheSystemBlog/~3/LD4QgUgPJVg/</link>
		<comments>http://remy.supertext.ch/2011/11/a-wpf-project-running-from-the-cmd-prompt-or-as-a-service-and-has-a-gui/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 16:37:23 +0000</pubDate>
		<dc:creator>Rémy Blättler</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Cmd]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Service]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://remy.supertext.ch/?p=299</guid>
		<description><![CDATA[Very often it’s necessary to run scheduled jobs or maintenance tasks once a day, once a month or even every few minutes. This can be easily achieved by creating your own Windows Service. For example if you want to send &#8230; <a href="http://remy.supertext.ch/2011/11/a-wpf-project-running-from-the-cmd-prompt-or-as-a-service-and-has-a-gui/">[weiterlesen]</a>]]></description>
			<content:encoded><![CDATA[<div class="google_plus_one"><g:plusone size="standard" count="false" url="http://remy.supertext.ch/2011/11/a-wpf-project-running-from-the-cmd-prompt-or-as-a-service-and-has-a-gui/"></g:plusone></div><p>Very often it’s necessary to run scheduled jobs or maintenance tasks once a day, once a month or even every few minutes. This can be easily achieved by creating your own Windows Service. For example if you want to send reminder e-mails to your customers. But wouldn’t it be nice to be able to also call the application from the command line so that it can do all the work and shut down afterwards? There is even a possibility of making a small script that calls all your similar applications, checks if any work has to be done, does the work and then shuts down. Also, you would like to make it possible to check for any work that needs to be done just by clicking on one button? Well, here you can find a very simple example on how all of this can be done.</p>
<p>First we need a class that is derived from ServiceBase. In that class need a public constructor, an OnStart and an OnStop method. For example, we want to make a service that does some usefull work every 4 minutes. An example of the code for the ServiceBase derived class is given next.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ServiceClass <span style="color: #008000;">:</span> ServiceBase
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Timers</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Timer</span> timer <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Timers</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Timer</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">300000</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Public constructor that initializes the service and</span>
    <span style="color: #008080; font-style: italic;">/// sets its parameters like ServiceName.</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> ServiceClass<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        CanPauseAndContinue <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        CanShutdown <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        ServiceName <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;My Service Name&quot;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Method specifies what code to execute each time a service</span>
    <span style="color: #008080; font-style: italic;">/// is started. Here it configures parameters for the timer</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;args&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnStart<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        timer<span style="color: #008000;">.</span><span style="color: #0000FF;">Enabled</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        timer<span style="color: #008000;">.</span><span style="color: #0000FF;">AutoReset</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        timer<span style="color: #008000;">.</span><span style="color: #0000FF;">Elapsed</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> ElapsedEventHandler<span style="color: #008000;">&#40;</span>OnTimedEvent<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Method specifies what code to execute each time a service</span>
    <span style="color: #008080; font-style: italic;">/// is stopped. Here it configures parameters for the timer. </span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnStop<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        timer<span style="color: #008000;">.</span><span style="color: #0000FF;">Enabled</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Method specifies what code to execute each time a timer's</span>
    <span style="color: #008080; font-style: italic;">/// interval is up. Here will be all the code that has to be done</span>
    <span style="color: #008080; font-style: italic;">/// continuously. </span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;source&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;e&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnTimedEvent<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> source, ElapsedEventArgs e<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">//do some work</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>We also need a class that extends the class Installer. In that class we need to define at least the class constructor method. There we create all the installer objects  necessary  to install the application as a service.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">&nbsp;
<span style="color: #008000;">&#91;</span>RunInstaller<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> MyProjectInstaller <span style="color: #008000;">:</span> Installer
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> ServiceInstaller serviceInstaller<span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> ServiceProcessInstaller processInstaller<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The public constructor that is executed when the</span>
    <span style="color: #008080; font-style: italic;">/// installation is started.</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> MyProjectInstaller<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        processInstaller <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ServiceProcessInstaller<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        serviceInstaller <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ServiceInstaller<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        processInstaller<span style="color: #008000;">.</span><span style="color: #0000FF;">Account</span> <span style="color: #008000;">=</span> ServiceAccount<span style="color: #008000;">.</span><span style="color: #0000FF;">LocalSystem</span><span style="color: #008000;">;</span>
&nbsp;
        serviceInstaller<span style="color: #008000;">.</span><span style="color: #0000FF;">StartType</span> <span style="color: #008000;">=</span> ServiceStartMode<span style="color: #008000;">.</span><span style="color: #0000FF;">Automatic</span><span style="color: #008000;">;</span>
        serviceInstaller<span style="color: #008000;">.</span><span style="color: #0000FF;">ServiceName</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;My Service Name&quot;</span><span style="color: #008000;">;</span>
&nbsp;
        Installers<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>serviceInstaller<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        Installers<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>processInstaller<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>   
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>The code given here is the minimal code needed for the service to be installed. In the class constructor we first need to instantiate the installer objects needed for the installation. One installer is an object from the class ServiceProcessInstaller and the other one is an object of the class ServiceInstaller. Then we set up all the information about the service – how will the service start (automatically), on what account will the service run(local system) and the name of the service (My Service Name). The name has to be the same as the name defined in the ServiceBase derived class. In the end we add the two created installers to the collection of installers.<br />
If we want some additional work done on each install or uninstall, it is possible to override the methods OnBeforeInstall and OnBeforeUninstall. For example, if we want the service to be started only if there is a certain parameter, it is possible to add this code :</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">&nbsp;
<span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnBeforeInstall<span style="color: #008000;">&#40;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Collections</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">IDictionary</span> savedState<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    Context<span style="color: #008000;">.</span><span style="color: #0000FF;">Parameters</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;assemblypath&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #008000;">+</span> 
        Context<span style="color: #008000;">.</span><span style="color: #0000FF;">Parameters</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;assemblypath&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\&quot;</span> -service&quot;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnBeforeInstall</span><span style="color: #008000;">&#40;</span>savedState<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnBeforeUninstall<span style="color: #008000;">&#40;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Collections</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">IDictionary</span> savedState<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    Context<span style="color: #008000;">.</span><span style="color: #0000FF;">Parameters</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;assemblypath&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #008000;">+</span> 
        Context<span style="color: #008000;">.</span><span style="color: #0000FF;">Parameters</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;assemblypath&quot;</span><span style="color: #008000;">&#93;</span>   <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\&quot;</span> -service&quot;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnBeforeUninstall</span><span style="color: #008000;">&#40;</span>savedState<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>After doing the work required for changing the call to the service, we call the same method from the base class in order to install the service correctly.<br />
After creating the two classes necessary for defining a windows service, we have to define the main application activity. So, what we have to do is add code that will define when the application will be executed as a windows service and when it’ll just do the work once and shutdown.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">partial</span> <span style="color: #6666cc; font-weight: bold;">class</span> App <span style="color: #008000;">:</span> Application
<span style="color: #008000;">&#123;</span>
   <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnStartup<span style="color: #008000;">&#40;</span>StartupEventArgs e<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
       <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnStartup</span><span style="color: #008000;">&#40;</span>e<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
       <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> commandLineArgs <span style="color: #008000;">=</span> <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Environment</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetCommandLineArgs</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
       <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>commandLineArgs<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&gt;</span><span style="color: #FF0000;">1</span> <span style="color: #008000;">&amp;&amp;</span> commandLineArgs<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;-someWork&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
       <span style="color: #008000;">&#123;</span>
         <span style="color: #008080; font-style: italic;">//do some work</span>
       <span style="color: #008000;">&#125;</span>
&nbsp;
       <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>commandLineArgs<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&gt;</span><span style="color: #FF0000;">1</span> <span style="color: #008000;">&amp;&amp;</span> commandLineArgs<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;-service&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> 
       <span style="color: #008000;">&#123;</span>
          ServiceBase<span style="color: #008000;">.</span><span style="color: #0000FF;">Run</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> ServiceClass<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
       <span style="color: #008000;">&#125;</span>
       <span style="color: #0600FF; font-weight: bold;">else</span>
       <span style="color: #008000;">&#123;</span>
          <span style="color: #008080; font-style: italic;">// do some work</span>
       <span style="color: #008000;">&#125;</span>  
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>This way it is possible to manage for the application to do different work when it’s called in different ways. All the work that the application does (as the service or called from the command line) should be defined in a separate class.<br />
In order to install the new service, open command prompt and type:</p>
<p><code>installutil ProjectName.exe<br />
</code><br />
where project name is the name of the project with the windows service and it’s installer. In order to uninstall the service type :</p>
<p><code>installutil /u ProjectName.exe<br />
</code><br />
And that’s it! Your service is ready to be used! Now if we want to be able to start the application with a user interface, it’s necessary to make some changes to the class App in the method OnStartup and we also have to define the class MainWindow which will contain the entire code that needs to be done through the user interface.<br />
In the case described above, the OnStartup class will look similar to this :</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">partial</span> <span style="color: #6666cc; font-weight: bold;">class</span> App <span style="color: #008000;">:</span> Application
<span style="color: #008000;">&#123;</span>
   <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnStartup<span style="color: #008000;">&#40;</span>StartupEventArgs e<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
       <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnStartup</span><span style="color: #008000;">&#40;</span>e<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
       <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> commandLineArgs <span style="color: #008000;">=</span> <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Environment</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetCommandLineArgs</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
       <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>commandLineArgs<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&gt;</span><span style="color: #FF0000;">1</span> <span style="color: #008000;">&amp;&amp;</span> commandLineArgs<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;-someWork&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
       <span style="color: #008000;">&#123;</span>
	   <span style="color: #008080; font-style: italic;">//starting the application with the appropriate command arguments will start </span>
	   <span style="color: #008080; font-style: italic;">//it in console mode</span>
           MainWindow f <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MainWindow<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
           f<span style="color: #008000;">.</span><span style="color: #0000FF;">ConsoleMode</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
           <span style="color: #008080; font-style: italic;">//do some work</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>commandLineArgs<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&gt;</span><span style="color: #FF0000;">1</span> <span style="color: #008000;">&amp;&amp;</span> commandLineArgs<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;-service&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> 
        <span style="color: #008000;">&#123;</span>
	    <span style="color: #008080; font-style: italic;">//start application as a service</span>
            ServiceBase<span style="color: #008000;">.</span><span style="color: #0000FF;">Run</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> ServiceClass<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">//in case there were no command arguments, start the user interface and do    //some work</span>
            MainWindow f <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MainWindow<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            f<span style="color: #008000;">.</span><span style="color: #0000FF;">ShowDialog</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Shutdown</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>            
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>In the class Application there is a property ConsoleMode which is used to indicate whether or not the application mode of running is console mode. Property ConsoleMode is defined in the class that defines the user interface, MainWindow. If we are also using some of the methods defined in the class MainWindow even when we start the application from the command line, we have to find a way to indicate that the application should shut down after the work is done. That’s why in the class that describes the user interface we have to add this wherever we want to check if the application needs to be shut down:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>ConsoleMode<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    Dispatcher<span style="color: #008000;">.</span><span style="color: #0000FF;">Invoke</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> Action<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> <span style="color: #008000;">&#123;</span> Application<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Shutdown</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p> And that’s it! Now you have built your first application that can be used as a windows service, with a user interface or called from the command line. </p>
<img src="http://feeds.feedburner.com/~r/ChiefOfTheSystemBlog/~4/LD4QgUgPJVg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://remy.supertext.ch/2011/11/a-wpf-project-running-from-the-cmd-prompt-or-as-a-service-and-has-a-gui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://remy.supertext.ch/2011/11/a-wpf-project-running-from-the-cmd-prompt-or-as-a-service-and-has-a-gui/</feedburner:origLink></item>
		<item>
		<title>IE9 does not color links anymore</title>
		<link>http://feedproxy.google.com/~r/ChiefOfTheSystemBlog/~3/kFFYtUy8VRQ/</link>
		<comments>http://remy.supertext.ch/2011/10/ie9-does-not-color-links-anymore/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 13:57:04 +0000</pubDate>
		<dc:creator>Rémy Blättler</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Browser History]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[IE9]]></category>

		<guid isPermaLink="false">http://remy.supertext.ch/?p=293</guid>
		<description><![CDATA[&#160; We run a few times into the issue, that IE9 does not save the browsing history anymore. Which results in all links loosing the different color after you click on them. There are different solutions for this on the &#8230; <a href="http://remy.supertext.ch/2011/10/ie9-does-not-color-links-anymore/">[weiterlesen]</a>]]></description>
			<content:encoded><![CDATA[<div class="google_plus_one"><g:plusone size="standard" count="false" url="http://remy.supertext.ch/2011/10/ie9-does-not-color-links-anymore/"></g:plusone></div><p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-295" title="IE9 Cache" src="http://remy.supertext.ch/wp-content/uploads/2011/10/IE9_Cache.png" alt="IE9 Cache" width="490" height="326" /></p>
<p>We run a few times into the issue, that IE9 does not save the browsing history anymore. Which results in all links loosing the different color after you click on them.</p>
<p>There are different solutions for this on the internet, the most common being to just clear your browser cache. Which unfortunately also clears all your passwords, links and defaults for forms.</p>
<p>Aber better but a bit more tricky way is to delete the index.dat file in the History directory.</p>
<p>Just follow the steps below:</p>
<ol>
<li>Open a Command Prompt Window (cmd.exe)This does NOT work with the Windows Explorer, you need the command line.</li>
<li>Go to C:\Users\&lt;&lt;UserName&gt;&gt;\AppData\Local\Microsoft\Windows\History(Replace &lt;&lt;UserName&gt;&gt; with your Windows account name)</li>
<li>cd Low</li>
<li>cd History.IE5</li>
<li>del/a index.dat</li>
</ol>
<p>That should be it. Let me know if it worked. It work for us.</p>
<img src="http://feeds.feedburner.com/~r/ChiefOfTheSystemBlog/~4/kFFYtUy8VRQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://remy.supertext.ch/2011/10/ie9-does-not-color-links-anymore/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://remy.supertext.ch/2011/10/ie9-does-not-color-links-anymore/</feedburner:origLink></item>
		<item>
		<title>Share SDL Trados Studio 2009 Projects</title>
		<link>http://feedproxy.google.com/~r/ChiefOfTheSystemBlog/~3/Jvks2MfxbrU/</link>
		<comments>http://remy.supertext.ch/2011/07/share-sdl-trados-studio-2009-projects/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 14:01:43 +0000</pubDate>
		<dc:creator>Rémy Blättler</dc:creator>
				<category><![CDATA[Multiterm]]></category>
		<category><![CDATA[Trados]]></category>
		<category><![CDATA[Translation]]></category>
		<category><![CDATA[SDL Trados Studio 2009]]></category>

		<guid isPermaLink="false">http://remy.supertext.ch/?p=288</guid>
		<description><![CDATA[Are you using any SDL Server products? Are you working in a team of more than one project manager or translator? How do you share your SDL Trados Projects, Translation Memories and Terminology Lists? Did you think this is not &#8230; <a href="http://remy.supertext.ch/2011/07/share-sdl-trados-studio-2009-projects/">[weiterlesen]</a>]]></description>
			<content:encoded><![CDATA[<div class="google_plus_one"><g:plusone size="standard" count="false" url="http://remy.supertext.ch/2011/07/share-sdl-trados-studio-2009-projects/"></g:plusone></div><p>Are you using any SDL Server products? Are you working in a team of more than one project manager or translator?</p>
<p>How do you share your SDL Trados Projects, Translation Memories and Terminology Lists? Did you think this is not possible without a Trados Server Product?</p>
<p>You might be wrong. Below you can see how we at <a title="Online translation and copywriting agency" href="http://www.supertext.ch/en">Supertext</a> are doing it.</p>
<p>&nbsp;</p>
<p>First, you need a shared network drive on a server or on any workstation that is constantly online.</p>
<p>Make sure this drive is mapped on every PC the same way. You do not need to assign a special drive letter, you can just use the name of that PC. Obviously every team member needs access to this folder.</p>
<p>In our case we named it like this:</p>
<p><span style="font-family: 'Courier New';">\\STORAGE\Open\Trados</span></p>
<p>We then created the following folder structure:</p>
<p><span style="font-family: 'Courier New';">Trados\SDL MultiTerm\Termbases</span></p>
<p><span style="font-family: 'Courier New';">Trados\SDL Trados Studio\Projects</span></p>
<p><span style="font-family: 'Courier New';">Trados\SDL Trados Studio\Translation Memories</span></p>
<p>You might notice that this is the standard Trados folder structure on your workstation. We figured it makes it easier for everybody to stay with what people are used to.</p>
<p>This is pretty much all there is. Just place your projects into the Projects folder, the TM into the Translation Memories folder and the Termbase into the Termbases folder.</p>
<p>This way everybody can access and update all  TM and Termbases without the need for an expensive Trados Server Product. You can also open all Return Packages, no matter if you created the inital Project or not. Just load the original Project first.</p>
<img src="http://feeds.feedburner.com/~r/ChiefOfTheSystemBlog/~4/Jvks2MfxbrU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://remy.supertext.ch/2011/07/share-sdl-trados-studio-2009-projects/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://remy.supertext.ch/2011/07/share-sdl-trados-studio-2009-projects/</feedburner:origLink></item>
		<item>
		<title>Download failed. Could not open handle for fopen()</title>
		<link>http://feedproxy.google.com/~r/ChiefOfTheSystemBlog/~3/hZ2YgMdzLf8/</link>
		<comments>http://remy.supertext.ch/2011/07/download-failed-could-not-open-handle-for-fopen/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 08:25:42 +0000</pubDate>
		<dc:creator>Rémy Blättler</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://remy.supertext.ch/2011/07/download-failed-could-not-open-handle-for-fopen/</guid>
		<description><![CDATA[I tried to use the automatic update feature for WordPress Plugins on my Windows Server 2008 R2 with IIS7. I setup the FTP account and entered the setting in WordPress. But unfortunately it did not work. After setting define(&#8216;WP_DEBUG&#8217;, true); &#8230; <a href="http://remy.supertext.ch/2011/07/download-failed-could-not-open-handle-for-fopen/">[weiterlesen]</a>]]></description>
			<content:encoded><![CDATA[<div class="google_plus_one"><g:plusone size="standard" count="false" url="http://remy.supertext.ch/2011/07/download-failed-could-not-open-handle-for-fopen/"></g:plusone></div><p>I tried to use the automatic update feature for WordPress Plugins on my Windows Server 2008 R2 with IIS7. I setup the FTP account and entered the setting in WordPress. But unfortunately it did not work.</p>
<p>After setting</p>
<p><span style="font-family: 'Courier New';">define(&#8216;WP_DEBUG&#8217;, true);</span></p>
<p>in the wp-config.php file I got the following error messages:</p>
<p>&nbsp;</p>
<p><span style="font-family: 'Courier New';">Updating Plugin SexyBookmarks (1/1)<br />
Downloading update from </span><a href="http://downloads.wordpress.org/plugin/sexybookmarks.4.0.4.2.zip…"><span style="font-family: 'Courier New';">http://downloads.wordpress.org/plugin/sexybookmarks.4.0.4.2.zip…</span></a></p>
<p><span style="font-family: 'Courier New';">Warning: touch() [function.touch]: Unable to create file C:\inetpub\wwwroot\some_blog/wp-content/sexybookmarks.tmp because Permission denied in C:\inetpub\wwwroot\some_blog\wp-admin\includes\file.php on line 177</span></p>
<p><span style="font-family: 'Courier New';">Warning: fopen(C:\inetpub\wwwroot\some_blog/wp-content/sexybookmarks.tmp) [function.fopen]: failed to open stream: Permission denied in C:\inetpub\wwwroot\some_blog\wp-includes\class-http.php on line 1070</span></p>
<p><span style="font-family: 'Courier New';">Warning: unlink(C:\inetpub\wwwroot\some_blog/wp-content/sexybookmarks.tmp) [function.unlink]: No such file or directory in C:\inetpub\wwwroot\some_blog\wp-admin\includes\file.php on line 489</span></p>
<p><span style="font-family: 'Courier New';">An error occurred while updating SexyBookmarks: Download failed. Could not open handle for fopen() to C:\inetpub\wwwroot\some_blog/wp-content/sexybookmarks.tmp.</span></p>
<p>&nbsp;</p>
<p>You need to do the following two things to fix this:</p>
<p>First, add this to your wp-config.php file:</p>
<p><span style="font-family: 'Courier New';">define(&#8216;WP_TEMP_DIR&#8217;,ABSPATH.&#8217;wp-content/uploads/&#8217;);</span></p>
<p>Second, give the IIS_IUSRS account read and write access to the wp-content folder.</p>
<p>That should help.</p>
<img src="http://feeds.feedburner.com/~r/ChiefOfTheSystemBlog/~4/hZ2YgMdzLf8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://remy.supertext.ch/2011/07/download-failed-could-not-open-handle-for-fopen/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://remy.supertext.ch/2011/07/download-failed-could-not-open-handle-for-fopen/</feedburner:origLink></item>
	</channel>
</rss>

