<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5081323865287565961</id><updated>2024-02-08T20:38:23.089+01:00</updated><category term="Basic HTTP authentication"/><category term="SQL Server"/><category term="Sony Ericsson X1"/><category term="WCF"/><category term="WCF Extension"/><category term="Windows Media Player"/><category term="Windows Mobile"/><category term="XPERIA"/><category term="pre-emptive"/><category term="preemptive"/><category term="wcf pre-emptive http basic authentication"/><category term="wma"/><title type='text'>Hallgrim</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ubcoder.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5081323865287565961/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://ubcoder.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Hallgrim</name><uri>http://www.blogger.com/profile/09679787310932454478</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5081323865287565961.post-7655265426371176983</id><published>2012-07-19T15:12:00.002+02:00</published><updated>2012-07-19T15:12:18.177+02:00</updated><title type='text'>Add querystring parameter to ASP.NET MVC RedirectToAction</title><content type='html'>&lt;br /&gt;
So you are doing&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;return this.RedirectToAction(c=&amp;gt;c.MyAction());&lt;/span&gt;&lt;/blockquote&gt;
or maybe&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;return this.RedirectToAction(&quot;&lt;/span&gt;MyAction&lt;span style=&quot;background-color: white;&quot;&gt;&quot;, &quot;MyController&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;You would love to add a querystring parameter to the request. Why would I want that, you say. Imagine you want to e.g. track goals in Google Analytics. One way of doing that is by adding a querystring parameter to the URL, say http://blabla.com/MyController/MyAction?gagoal=achievedgoal1.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Any parameter not part of the route will be passed as querystringparameter:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;return this.RedirectToAction(c=&amp;gt;c.MyPage()), new {gagoal=&quot;achievedgoal1&quot;});&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
So, why not make it more explicit and fluent like this?&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;return this.RedirectToAction(c=&amp;gt;c.MyAction()).WithQuery(&quot;gagoal&quot;, &quot;achievedgoal1&quot;);&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;return this.RedirectToAction(c=&amp;gt;c.MyAction()))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;.WithQuery(&quot;gagoal&quot;, &quot;achievedgoal1&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;.And(&quot;otherparameter&quot;, &quot;othervalue&quot;);&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
Here is the code&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;  &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; RedirectToRouteExtensions
    {
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; RedirectToRouteResult WithQuery(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt; RedirectToRouteResult redirectResult,&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; name, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; val)
        {
            redirectResult.RouteValues.Add(name, val);
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; redirectResult;
        }
        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; RedirectToRouteResult And(&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt; RedirectToRouteResult redirectResult,&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; name, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; val)
        {
            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; redirectResult.WithQuery(name, val);
        }

    }&lt;/pre&gt;
So when I add GA goals I use another extension method:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;return this.RedirectToAction(c=&amp;gt;c.MyAction()).WithGAGoal(&quot;loginok&quot;);&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
Here is the code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; public static class GAGoalsExtensions&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public static RedirectToRouteResult WithGAGoal(this RedirectToRouteResult redirectResult, string val)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return redirectResult.&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;WithQuery(Constants.GAGoalQueryStringName, val)&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: &#39;Courier New&#39;, Courier, monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://ubcoder.blogspot.com/feeds/7655265426371176983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ubcoder.blogspot.com/2012/07/add-querystring-parameter-to-aspnet-mvc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5081323865287565961/posts/default/7655265426371176983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5081323865287565961/posts/default/7655265426371176983'/><link rel='alternate' type='text/html' href='http://ubcoder.blogspot.com/2012/07/add-querystring-parameter-to-aspnet-mvc.html' title='Add querystring parameter to ASP.NET MVC RedirectToAction'/><author><name>Hallgrim</name><uri>http://www.blogger.com/profile/09679787310932454478</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5081323865287565961.post-1592774450441560349</id><published>2009-09-15T11:50:00.009+02:00</published><updated>2009-09-15T13:55:15.572+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Basic HTTP authentication"/><category scheme="http://www.blogger.com/atom/ns#" term="pre-emptive"/><category scheme="http://www.blogger.com/atom/ns#" term="preemptive"/><category scheme="http://www.blogger.com/atom/ns#" term="WCF"/><category scheme="http://www.blogger.com/atom/ns#" term="WCF Extension"/><category scheme="http://www.blogger.com/atom/ns#" term="wcf pre-emptive http basic authentication"/><title type='text'>Basic HTTP authentication over SSL in WCF</title><content type='html'>Tried to figure this out for a while, but decided to do my own WCF extension to fix it.&lt;br /&gt;&lt;br /&gt;We are integrating against a third party service that requires pre-emptive HTTP/1.1 Basic Authentication and SSL. The authentication header must be set on very request.&lt;br /&gt;&lt;br /&gt;So I tried different binding configurations, but none seemed to fit the requirements. So I decided to make a IClientMessageInspector implementation to add the HTTP-header my self. There are tons of examples of this on the net. What I wanted was the ability to also use the configuration file to provide the username and password, so I also added a configuration property.&lt;br /&gt;&lt;br /&gt;The configuration looks like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;system.servicemodel&amp;gt;&lt;br /&gt;&amp;lt;extensions&amp;gt;&lt;br /&gt;  &amp;lt;behaviorextensions&amp;gt;&lt;br /&gt;    &amp;lt;add name=&quot;httpBasicAuthenticationBehavior&quot; type=&quot;Flatland.WCF.HTTPBasicAuthenticationBehaviorExtensionElement, Flatland.WCF Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&quot;&amp;gt;&lt;br /&gt;  &amp;lt;/behaviorextensions&amp;gt;&lt;br /&gt;&amp;lt;/extensions&amp;gt;&lt;br /&gt;&amp;lt;behaviors&amp;gt;&lt;br /&gt;  &amp;lt;endpointbehaviors&amp;gt;&lt;br /&gt;    &amp;lt;behavior name=&quot;myThirdpartyBasicAuthBehavior&quot;&amp;gt;&lt;br /&gt;      &amp;lt;httpBasicAuthenticationBehavior Username=&quot;myusername&quot; Password=&quot;mypassword&quot;&amp;gt;&lt;br /&gt;    &amp;lt;/behavior&amp;gt;&lt;br /&gt;  &amp;lt;/endpointbehaviors&amp;gt;&lt;br /&gt;&amp;lt;/behaviors&amp;gt;&lt;br /&gt;&amp;lt;bindings&amp;gt;&lt;br /&gt;  &amp;lt;basichttpbinding&amp;gt;&lt;br /&gt;    &amp;lt;binding name=&quot;SSLBindingConfiguration&quot;&lt;br /&gt;        maxBufferSize=&quot;2147483647&quot; maxReceivedMessageSize=&quot;2147483647&quot;&amp;gt;&lt;br /&gt;      &amp;lt;security mode=&quot;Transport&quot;&amp;gt;&lt;br /&gt;      &amp;lt;/security&amp;gt;&lt;br /&gt;    &amp;lt;/binding&amp;gt;&lt;br /&gt;  &amp;lt;/basichttpbinding&amp;gt;&lt;br /&gt;&amp;lt;/bindings&amp;gt;&lt;br /&gt;&amp;lt;client&amp;gt;&lt;br /&gt;  &amp;lt;endpoint&lt;br /&gt;    behaviorConfiguration=&quot;myThirdpartyBasicAuthBehavior&quot;&lt;br /&gt;    address=&quot;https://thirdparty.com/somepath/service1&quot;&lt;br /&gt;    binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;SSLBindingConfiguration&quot;&lt;br /&gt;    contract=&quot;ThirdpartyContracts.Contract1&quot;&lt;br /&gt;    name=&quot;MyThirdpartyEndpoint&quot; /&amp;gt;&lt;br /&gt;&amp;lt;/client&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;diagnostics wmiproviderenabled=&quot;true&quot;&amp;gt;&lt;br /&gt;  &amp;lt;messageLogging&lt;br /&gt;       logEntireMessage=&quot;true&quot;&lt;br /&gt;       logMalformedMessages=&quot;true&quot;&lt;br /&gt;       logMessagesAtServiceLevel=&quot;true&quot;&lt;br /&gt;       logMessagesAtTransportLevel=&quot;true&quot;&lt;br /&gt;       maxMessagesToLog=&quot;30000&quot;&lt;br /&gt;       maxSizeOfMessageToLog=&quot;20000000&quot;/&amp;gt;&lt;br /&gt;&amp;lt;/diagnostics&amp;gt;&lt;br /&gt;&amp;lt;/system.serviceModel&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is the code:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Net;&lt;br /&gt;using System.ServiceModel;&lt;br /&gt;using System.ServiceModel.Channels;&lt;br /&gt;using System.ServiceModel.Configuration;&lt;br /&gt;using System.ServiceModel.Description;&lt;br /&gt;using System.ServiceModel.Dispatcher;&lt;br /&gt;using System.Text;&lt;br /&gt;&lt;br /&gt;namespace Flatland.WCF&lt;br /&gt;{&lt;br /&gt;public class HTTPBasicAuthenticationBehaviorExtensionElement : BehaviorExtensionElement&lt;br /&gt;{&lt;br /&gt;    [ConfigurationProperty(&quot;Username&quot;, IsRequired = true)]&lt;br /&gt;    public virtual string Username&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            return this[&quot;Username&quot;] as string;&lt;br /&gt;        }&lt;br /&gt;        set&lt;br /&gt;        {&lt;br /&gt;            this[&quot;Username&quot;] = value;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [ConfigurationProperty(&quot;Password&quot;, IsRequired = true)]&lt;br /&gt;    public virtual string Password&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            return this[&quot;Password&quot;] as string;&lt;br /&gt;        }&lt;br /&gt;        set&lt;br /&gt;        {&lt;br /&gt;            this[&quot;Password&quot;] = value;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected override object CreateBehavior()&lt;br /&gt;    {&lt;br /&gt;        return new HTTPBasicAuthenticationBehavior(Username, Password);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public override Type BehaviorType&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            return typeof(HTTPBasicAuthenticationBehavior);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class HTTPBasicAuthenticationBehavior : IEndpointBehavior&lt;br /&gt;{&lt;br /&gt;    private readonly string _username;&lt;br /&gt;    private readonly string _password;&lt;br /&gt;&lt;br /&gt;    public HTTPBasicAuthenticationBehavior(string username, string password)&lt;br /&gt;    {&lt;br /&gt;        _username = username;&lt;br /&gt;        _password = password;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void Validate(ServiceEndpoint endpoint)&lt;br /&gt;    {&lt;br /&gt;        return;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)&lt;br /&gt;    {&lt;br /&gt;        return;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)&lt;br /&gt;    {&lt;br /&gt;        return;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)&lt;br /&gt;    {&lt;br /&gt;        clientRuntime.MessageInspectors.Add(new HTTPBasicAuthenticationMessageInspector(_username, _password));&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class HTTPBasicAuthenticationMessageInspector : IClientMessageInspector&lt;br /&gt;{&lt;br /&gt;    private readonly string _username;&lt;br /&gt;    private readonly string _password;&lt;br /&gt;&lt;br /&gt;    public HTTPBasicAuthenticationMessageInspector(string username, string password)&lt;br /&gt;    {&lt;br /&gt;        _username = username;&lt;br /&gt;        _password = password;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public object BeforeSendRequest(ref Message request, IClientChannel channel)&lt;br /&gt;    {&lt;br /&gt;        HttpRequestMessageProperty httpRequest = null;&lt;br /&gt;        if (request.Properties.ContainsKey(HttpRequestMessageProperty.Name))&lt;br /&gt;        {&lt;br /&gt;            httpRequest = request.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        //Make sure we have a valid property, or create one&lt;br /&gt;        if (httpRequest == null)&lt;br /&gt;        {&lt;br /&gt;            httpRequest = new HttpRequestMessageProperty();&lt;br /&gt;            request.Properties.Add(HttpRequestMessageProperty.Name, httpRequest);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        string encodedCredentials = EncodeCredentials(_username, _password);&lt;br /&gt;        httpRequest.Headers[HttpRequestHeader.Authorization] = &quot;Basic &quot; + encodedCredentials;&lt;br /&gt;&lt;br /&gt;        return null;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private string EncodeCredentials(string username, string password)&lt;br /&gt;    {&lt;br /&gt;        string clearTextCredentials = string.Format(&quot;{0}:{1}&quot;, username, password);&lt;br /&gt;        var inArray = Encoding.UTF8.GetBytes(clearTextCredentials);&lt;br /&gt;        return Convert.ToBase64String(inArray);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void AfterReceiveReply(ref Message reply, object correlationState)&lt;br /&gt;    {&lt;br /&gt;        return;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://ubcoder.blogspot.com/feeds/1592774450441560349/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ubcoder.blogspot.com/2009/09/basic-http-authentication-over-ssl-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5081323865287565961/posts/default/1592774450441560349'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5081323865287565961/posts/default/1592774450441560349'/><link rel='alternate' type='text/html' href='http://ubcoder.blogspot.com/2009/09/basic-http-authentication-over-ssl-in.html' title='Basic HTTP authentication over SSL in WCF'/><author><name>Hallgrim</name><uri>http://www.blogger.com/profile/09679787310932454478</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5081323865287565961.post-3164163371875783082</id><published>2009-08-08T21:53:00.003+02:00</published><updated>2009-08-08T22:05:35.583+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Sony Ericsson X1"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Media Player"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Mobile"/><category scheme="http://www.blogger.com/atom/ns#" term="wma"/><category scheme="http://www.blogger.com/atom/ns#" term="XPERIA"/><title type='text'>Using Windows Media Player in a Windows Mobile application</title><content type='html'>So I wanted to play a .wma file in my Windows Mobile application. I am using a Sony Ericsson X1. System.Media is not the answer as it only plays .wav files. So I looked into using the Windows Media Player Interop.&lt;br /&gt;&lt;br /&gt;Add reference ==&gt; Browse ==&gt;  Select the file &quot;c:\Windows\System32\wmp.dll&quot;&lt;br /&gt;&lt;br /&gt;To play a simple .wma file you can do something like this:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;using WMPLib;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        private readonly WindowsMediaPlayer _player;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        public Form1()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;            InitializeComponent();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;_player = new WindowsMediaPlayerClass();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;            _player.uiMode = &quot;invisible&quot;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        private void SoundAlarm()&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;_player.URL = &lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;@&quot;\Windows\Rings\Telephone ring 1.wma&quot;&lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;            _player.controls.play();&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;        }&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://ubcoder.blogspot.com/feeds/3164163371875783082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ubcoder.blogspot.com/2009/08/using-windows-media-player-in-windows.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5081323865287565961/posts/default/3164163371875783082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5081323865287565961/posts/default/3164163371875783082'/><link rel='alternate' type='text/html' href='http://ubcoder.blogspot.com/2009/08/using-windows-media-player-in-windows.html' title='Using Windows Media Player in a Windows Mobile application'/><author><name>Hallgrim</name><uri>http://www.blogger.com/profile/09679787310932454478</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5081323865287565961.post-3847611236737837021</id><published>2009-07-10T11:49:00.002+02:00</published><updated>2009-07-10T11:51:13.089+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Running SQL Server Management Studio from a computer not in the domain</title><content type='html'>&lt;span xmlns=&quot;&quot;&gt;&lt;p&gt;The case: My domain user has access to the SQL Server box (which is also registered in the domain). My dev-pc is not in the domain. I want to run SQL Server Management Studio on my local computer to access my SQL Server.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;You try using SQL Server Authentication typing &amp;lt;DOMAIN&amp;gt;\username. Alas! &quot;Cannot connect to &amp;lt;servername&amp;gt;&quot;. Additional information: Login failed for user &#39;&amp;lt;DOMAIN&amp;gt;\username&#39;. (Microsoft SQL Server, Error: 18456)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;To be able to do this, you must run the Management studio as the domain user. This is not possible you say? When you do RunAs, it will not accept the domain user. You must run the command with the /netonly switch. Then it works like a charm.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;Runas /netonly /user:&amp;lt;domain&amp;gt;\&amp;lt;username&amp;gt; &amp;lt;command&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;But hey! There is a better way. Download &lt;a target=&quot;_blank&quot; href=&quot;http://technet.microsoft.com/en-us/sysinternals/cc300361.aspx&quot;&gt;ShellRunas&lt;/a&gt; by Mark Russinovich and Jon Schwartz. This is a shell extension that lets you right click any application and choos runas or runas (notonly).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Just remember to register it correctly. You have to run both this commands. Then you are good to go.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;ShellRunas.exe /reg&lt;br /&gt;ShellRunas.exe /regnetonly&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Now you can right-click SQL Server Management Studio, choose &quot;Run as different user (netonly)…&quot; and give &amp;lt;DOMAIN&amp;gt;\&amp;lt;username&amp;gt; plus password. When connecting to database, choose Windows authentication.&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://ubcoder.blogspot.com/feeds/3847611236737837021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ubcoder.blogspot.com/2009/07/running-sql-server-management-studio.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5081323865287565961/posts/default/3847611236737837021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5081323865287565961/posts/default/3847611236737837021'/><link rel='alternate' type='text/html' href='http://ubcoder.blogspot.com/2009/07/running-sql-server-management-studio.html' title='Running SQL Server Management Studio from a computer not in the domain'/><author><name>Hallgrim</name><uri>http://www.blogger.com/profile/09679787310932454478</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5081323865287565961.post-3053293354470963316</id><published>2009-07-09T10:27:00.001+02:00</published><updated>2009-07-09T10:29:03.670+02:00</updated><title type='text'>Giving something back</title><content type='html'>Finally I got around to create a blog. This blog will mainly contain .NET stuff I get cought up in at work. Looking forward to put something back into the community.&lt;br /&gt;&lt;br /&gt;/Hallgrim</content><link rel='replies' type='application/atom+xml' href='http://ubcoder.blogspot.com/feeds/3053293354470963316/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ubcoder.blogspot.com/2009/07/giving-something-back.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5081323865287565961/posts/default/3053293354470963316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5081323865287565961/posts/default/3053293354470963316'/><link rel='alternate' type='text/html' href='http://ubcoder.blogspot.com/2009/07/giving-something-back.html' title='Giving something back'/><author><name>Hallgrim</name><uri>http://www.blogger.com/profile/09679787310932454478</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>