<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Felix's Weblog</title>
	<atom:link href="http://felixchu.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://felixchu.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sat, 14 May 2011 11:13:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='felixchu.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Felix's Weblog</title>
		<link>http://felixchu.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://felixchu.wordpress.com/osd.xml" title="Felix&#039;s Weblog" />
	<atom:link rel='hub' href='http://felixchu.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Coding style: bools, structs or enums</title>
		<link>http://felixchu.wordpress.com/2008/04/11/coding-style-bools-structs-or-enums/</link>
		<comments>http://felixchu.wordpress.com/2008/04/11/coding-style-bools-structs-or-enums/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 04:58:17 +0000</pubDate>
		<dc:creator>felixch</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding style]]></category>

		<guid isPermaLink="false">http://felixchu.wordpress.com/?p=7</guid>
		<description><![CDATA[Read an article about writing methods where you have to provide multiple boolean options for input: http://blogs.msdn.com/kevinpilchbisson/archive/2007/11/30/coding-styles-bools-structs-or-enums.aspx Instead of defining each option in the method signature: Func1(boolean option1, boolean option2), You can define a enum OptionEnum {   option1 = 0&#215;1;   option2 = 0&#215;2;   optionboth = (option1 &#124; option2); } or Define a struct  struct Option {   [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=7&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Read an article about writing methods where you have to provide multiple boolean options for input:</p>
<p><a href="http://blogs.msdn.com/kevinpilchbisson/archive/2007/11/30/coding-styles-bools-structs-or-enums.aspx">http://blogs.msdn.com/kevinpilchbisson/archive/2007/11/30/coding-styles-bools-structs-or-enums.aspx</a></p>
<p>Instead of defining each option in the method signature:</p>
<p>Func1(boolean option1, boolean option2),</p>
<p>You can define a enum</p>
<p>OptionEnum {</p>
<p>  option1 = 0&#215;1;</p>
<p>  option2 = 0&#215;2;</p>
<p>  optionboth = (option1 | option2);</p>
<p>}</p>
<p>or Define a struct</p>
<p> struct Option {</p>
<p>  bool option1;</p>
<p>  bool option2;</p>
<p>}</p>
<p>I agree with the author that it&#8217;s better to use Struct when you have lots of options and you have to define options for every possible combinations</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/felixchu.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/felixchu.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/felixchu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/felixchu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/felixchu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/felixchu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/felixchu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/felixchu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/felixchu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/felixchu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/felixchu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/felixchu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/felixchu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/felixchu.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/felixchu.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/felixchu.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=7&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://felixchu.wordpress.com/2008/04/11/coding-style-bools-structs-or-enums/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8ac70264161540b01ce57a906a75c29?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">felix</media:title>
		</media:content>
	</item>
		<item>
		<title>Access UI thread objects from non-UI thread</title>
		<link>http://felixchu.wordpress.com/2008/04/10/access-ui-thread-objects-from-non-ui-thread/</link>
		<comments>http://felixchu.wordpress.com/2008/04/10/access-ui-thread-objects-from-non-ui-thread/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 15:35:04 +0000</pubDate>
		<dc:creator>felixch</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Threading]]></category>
		<category><![CDATA[Add new tag]]></category>

		<guid isPermaLink="false">http://felixchu.wordpress.com/?p=6</guid>
		<description><![CDATA[Some articles which talk about how to change UI thread objects from non-UI thread http://msdn2.microsoft.com/en-au/library/ms171728(VS.80).aspx http://davebrooks.wordpress.com/2007/02/12/begininvoke-the-land-of-confusion The function below demonstrates how to do access UI thread object from non-UI thread. When you want to set the button text from a non-UI thread, use button.InvokeRequired to check whether it is a UI thread. If it returns true (it&#8217;s a non-UI thread), calls SetText [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=6&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Some articles which talk about how to change UI thread objects from non-UI thread</p>
<p><a href="http://msdn2.microsoft.com/en-au/library/ms171728(VS.80).aspx">http://msdn2.microsoft.com/en-au/library/ms171728(VS.80).aspx</a></p>
<p><a href="http://davebrooks.wordpress.com/2007/02/12/begininvoke-the-land-of-confusion">http://davebrooks.wordpress.com/2007/02/12/begininvoke-the-land-of-confusion</a></p>
<p>The function below demonstrates how to do access UI thread object from non-UI thread. When you want to set the button text from a non-UI thread, use button.InvokeRequired to check whether it is a UI thread. If it returns true (it&#8217;s a non-UI thread), calls SetText again using Form.Invoke. It would start the UI thread and the thread would be able to set the text property.</p>
<p>private void SetText(string text)<br />
{<br />
 <br />
    // InvokeRequired required compares the thread ID of the<br />
    // calling thread to the thread ID of the creating thread.<br />
    // If these threads are different, it returns true.<br />
    if (this.button1.InvokeRequired)<br />
    {<br />
 <br />
        SetTextCallback d = new SetTextCallback(SetText);<br />
        this.Invoke(d, new object[] { text });<br />
    }<br />
    else<br />
    {<br />
        this.button1.Text = text;<br />
    }<br />
}</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/felixchu.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/felixchu.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/felixchu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/felixchu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/felixchu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/felixchu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/felixchu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/felixchu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/felixchu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/felixchu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/felixchu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/felixchu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/felixchu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/felixchu.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/felixchu.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/felixchu.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=6&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://felixchu.wordpress.com/2008/04/10/access-ui-thread-objects-from-non-ui-thread/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8ac70264161540b01ce57a906a75c29?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">felix</media:title>
		</media:content>
	</item>
		<item>
		<title>throw vs throw ex</title>
		<link>http://felixchu.wordpress.com/2008/04/10/throw-vs-throw-ex/</link>
		<comments>http://felixchu.wordpress.com/2008/04/10/throw-vs-throw-ex/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 08:22:40 +0000</pubDate>
		<dc:creator>felixch</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Exception]]></category>

		<guid isPermaLink="false">http://felixchu.wordpress.com/?p=5</guid>
		<description><![CDATA[Find a good article explaining how to rethrow exception in .Net: http://weblogs.asp.net/bhouse/archive/2004/11/30/272297.aspx To rethrow an exception in C# without losting the original stack trace info: try { } catch {   throw; } To re-throw execption without preserving th original stack track: try { } catch (Exception e) {  throw e; }  <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=5&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Find a good article explaining how to rethrow exception in .Net: <a href="http://weblogs.asp.net/bhouse/archive/2004/11/30/272297.aspx">http://weblogs.asp.net/bhouse/archive/2004/11/30/272297.aspx</a></p>
<p>To rethrow an exception in C# without losting the original stack trace info:</p>
<p>try {</p>
<p>}<br />
catch<br />
{<br />
  throw;<br />
}</p>
<p>To re-throw execption without preserving th original stack track:</p>
<p>try {</p>
<p>}<br />
catch (Exception e)<br />
{<br />
 throw e;<br />
}</p>
<p> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/felixchu.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/felixchu.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/felixchu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/felixchu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/felixchu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/felixchu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/felixchu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/felixchu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/felixchu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/felixchu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/felixchu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/felixchu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/felixchu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/felixchu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/felixchu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/felixchu.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=5&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://felixchu.wordpress.com/2008/04/10/throw-vs-throw-ex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8ac70264161540b01ce57a906a75c29?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">felix</media:title>
		</media:content>
	</item>
		<item>
		<title>writing web service for sharepoint</title>
		<link>http://felixchu.wordpress.com/2008/04/10/wirting-web-service-for-sharepoint/</link>
		<comments>http://felixchu.wordpress.com/2008/04/10/wirting-web-service-for-sharepoint/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 06:43:46 +0000</pubDate>
		<dc:creator>felixch</dc:creator>
				<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://felixchu.wordpress.com/?p=4</guid>
		<description><![CDATA[I need to create a Sharepoint web serivce at work. I follow the instructions from here but found it too long to read so I want to summarize the steps in here: 1. Create the web service. Register the dll into GAC by using gacutil /i dllname.dll. (If I don&#8217;t register dll into GAC it&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=4&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I need to create a Sharepoint web serivce at work. I follow the instructions from <a title="here" href="http://msdn2.microsoft.com/en-us/library/ms916810.aspx">here</a> but found it too long to read so I want to summarize the steps in here:</p>
<p>1. Create the web service. Register the dll into GAC by using gacutil /i dllname.dll. (If I don&#8217;t register dll into GAC it&#8217;s not working. I will just leave it for now and will investigate later).</p>
<p>2. Create the disco and wdsl file using this command from VS.Net command prompt:<br />
Disco http://server_name:New_Port/Project_Name/Service_1.asmx</p>
<p>3. Rename service1.disco to service1disco.aspx. Open the file and replace this line:</p>
<p style="text-align:left;">&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;</p>
<p>to:</p>
<p>&lt;%@ Page Language=&#8221;C#&#8221; Inherits=&#8221;System.Web.UI.Page&#8221;%&gt; &lt;%@ Assembly Name=&#8221;Microsoft.SharePoint, Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&#8221; %&gt; &lt;%@ Import Namespace=&#8221;Microsoft.SharePoint.Utilities&#8221; %&gt; &lt;%@ Import Namespace=&#8221;Microsoft.SharePoint&#8221; %&gt;<br />
&lt;% Response.ContentType = &#8220;text/xml&#8221;; %&gt;</p>
<p>4. Rename Service1.wsdl to Service1wsdl.aspx and do the same thing to the file</p>
<p>5. Open Service1disco.aspx and locate</p>
<p>&lt;contractRef ref=&#8221;http://server_name:New_Port/Project_Name/Service1.asmx?wsdl&#8221; docRef=<br />
&#8220;http://server_name:New_Port/Project_Name/Service1.asmx&#8221; xmlns=&#8221;http://schemas.xmlsoap.org/disco/scl/&#8221; /&gt;</p>
<p>Change that to</p>
<p>&lt;contractRef ref=&lt;% SPEncode.WriteHtmlEncodeWithQuote(Response, SPWeb.OriginalBaseUrl(Request)<br />
+ &#8220;?wsdl&#8221;, &#8216;&#8221;&#8216;); %&gt; docRef=&lt;% SPEncode.WriteHtmlEncodeWithQuote(Response,<br />
SPWeb.OriginalBaseUrl(Request), &#8216;&#8221;&#8216;); %&gt; xmlns=&#8221;http://schemas.xmlsoap.org/disco/scl/&#8221; /&gt;</p>
<p>6. Locate the tag:</p>
<p>&lt;soap address=&#8221;http://server_name:New_Port/Project_Name/Service1.asmx&#8221; xmlns:q1=<br />
&#8220;http://tempuri.org/&#8221; binding=&#8221;q1:Service1Soap&#8221; xmlns=&#8221;http://schemas.xmlsoap.org/disco/soap/&#8221; /&gt;</p>
<p>and change it to</p>
<p>&lt;soap address=&lt;% SPEncode.WriteHtmlEncodeWithQuote(Response, SPWeb.OriginalBaseUrl<br />
(Request), &#8216;&#8221;&#8216;); %&gt; xmlns:q1=&#8221;http://tempuri.org/&#8221; binding=&#8221;q1:Service1Soap&#8221; xmlns=<br />
&#8220;http://schemas.xmlsoap.org/disco/soap/&#8221; /&gt;</p>
<p>7. Open Service1wsdl.aspx and locate</p>
<p>&lt;soap:address location=&#8221;http://server_name:New_Port/Project_Name/Service1.asmx&#8221; /&gt;</p>
<p>Change it to</p>
<p>&lt;soap:address location=&lt;% SPEncode.WriteHtmlEncodeWithQuote(Response,<br />
SPWeb.OriginalBaseUrl(Request), &#8216;&#8221;&#8216;); %&gt; /&gt;</p>
<p>8. Copy the Service1wsdl.aspx file, the Service1disco.aspx file, and the Service1.asmx file to c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI directory</p>
<p>9. Open c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI directory\spdisco.aspx. Add the following line to the end of the file within the discovery element:</p>
<p>&lt;contractRef ref=&lt;% SPEncode.WriteHtmlEncodeWithQuote(Response, spWeb.Url + /_vti_bin/Service1.asmx?wsdl&#8221;,<br />
&#8216;&#8221;&#8216;); %&gt; docRef=&lt;% SPEncode.WriteHtmlEncodeWithQuote(Response, spWeb.Url + &#8220;/_vti_bin/Service1.asmx&#8221;, &#8216;&#8221;&#8216;);<br />
%&gt; xmlns=&#8221;http://schemas.xmlsoap.org/disco/scl/&#8221; /&gt;&lt;soap address=&lt;%<br />
SPEncode.WriteHtmlEncodeWithQuote(Response, spWeb.Url + &#8220;/_vti_bin/Service1.asmx&#8221;, &#8216;&#8221;&#8216;); %&gt;<br />
xmlns:q1=&#8221;http://schemas.microsoft.com/sharepoint/soap/directory/&#8221; binding=&#8221;q1:Service1Soap&#8221;<br />
xmlns=&#8221;http://schemas.xmlsoap.org/disco/soap/&#8221; /&gt;</p>
<p>where binding=&#8221;q1:Service1Soap&#8221; specifiies the name of the class defined in the web service</p>
<p>10. try running the web service by entering http://sharepointserver_name:port/_vti_bin/Service1.asmx on the web browser.</p>
<p><strong>Note:</strong></p>
<p>1. When re-register gac, you have to restart IIS by typing iisreset<br />
2. To debug web serivce locally from Visual Studio. Attach the the project to the workerprocess &#8211; w3wp.exe.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/felixchu.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/felixchu.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/felixchu.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/felixchu.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/felixchu.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/felixchu.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/felixchu.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/felixchu.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/felixchu.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/felixchu.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/felixchu.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/felixchu.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/felixchu.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/felixchu.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/felixchu.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/felixchu.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=4&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://felixchu.wordpress.com/2008/04/10/wirting-web-service-for-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8ac70264161540b01ce57a906a75c29?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">felix</media:title>
		</media:content>
	</item>
		<item>
		<title>Principal Permission and Web Service Security</title>
		<link>http://felixchu.wordpress.com/2008/04/10/principal-permission/</link>
		<comments>http://felixchu.wordpress.com/2008/04/10/principal-permission/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 00:43:55 +0000</pubDate>
		<dc:creator>felixch</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://felixchu.wordpress.com/?p=3</guid>
		<description><![CDATA[I am developing a Web Service and want to find a good way to authenticate and authorize users to use the service. I have looked into Role-Based Security Check and done some investigation on PrincipalPermission and Web Sevice Security. Here are the things I have found out so far: PrincipalPermission 1 System.Threading.Thread.CurrentPrincipal.Identity stores the Identity of the Current [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=3&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am developing a Web Service and want to find a good way to authenticate and authorize users to use the service. I have looked into Role-Based Security Check and done some investigation on PrincipalPermission and Web Sevice Security. Here are the things I have found out so far:</p>
<p><strong>PrincipalPermission</strong></p>
<p>1 System.Threading.Thread.CurrentPrincipal.Identity stores the Identity of the Current Principal</p>
<p>2 Use PrincipalPermission declaratively &#8211; [PrincipalPermission(SecurityAction.Demand, Role ="Administrators")]. The downside of that is the Role have to be hardcoded to the attribute.</p>
<p>3. Use PrincipalPermission imperatively:</p>
<p>PrincipalPermission p = new PrincipalPermission(&#8220;user&#8217;, &#8220;role&#8221;);<br />
p.Demand();</p>
<p>p.Demand() is checking that if the current principal (System.Threading.Thread.CurrentPrincipal) matches the principal specified by the current permission.</p>
<p><strong>Web Service Security</strong></p>
<p>1 ASMX web service is actually an ASP.Net application. It&#8217;s mapped to aspnet_isapi.dll. Therefore we can use ASP.Net security mechanism to authenticate and authorize web service.</p>
<p>2 When writing a web service, it&#8217;s better to inherit from System.Web.Services.WebService becuase the class provides direct access to common ASP.Net objects. There is a <strong>User</strong> property in this class that gets the ASP.Net server System.Web.HttpContext.User object and can be used to autenticate whether a user is authorized to execute the request</p>
<p>3 Select Authentication mode from ASP.Net Configuration Settings</p>
<p>4 If using Windows authentication, you can set the authentication scheme from IIS -&gt; Directory Security -&gt; Authentication and access control to control the authentication of the web service</p>
<p>5 You can also set your authentication mode in Web.config</p>
<p>6 Select &#8220;None&#8221; for authentication mode if you want to use custom authication</p>
<p>7 Do not use &#8220;Form&#8221; or &#8220;Passport&#8221; Authentication for web service as they needed redirection to the login page</p>
<p>8 You can use ASP.Net Authorization (e.g. use IIS or web.config) to handle authorization on Web Service. However, I think the downside of that is you can only control it in page level but not method level.</p>
<p>9 You can use .Net Role Security Check to hanlde authorization on Web Service. This way authorization can be handled in method level  </p>
<p>Good article for web service security: <a href="http://www.15seconds.com/issue/020312.htm">http://www.15seconds.com/issue/020312.htm</a></p>
<p> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/felixchu.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/felixchu.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/felixchu.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/felixchu.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/felixchu.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/felixchu.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/felixchu.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/felixchu.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/felixchu.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/felixchu.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/felixchu.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/felixchu.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/felixchu.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/felixchu.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/felixchu.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/felixchu.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=3&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://felixchu.wordpress.com/2008/04/10/principal-permission/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8ac70264161540b01ce57a906a75c29?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">felix</media:title>
		</media:content>
	</item>
		<item>
		<title>First post</title>
		<link>http://felixchu.wordpress.com/2008/04/10/hello-world/</link>
		<comments>http://felixchu.wordpress.com/2008/04/10/hello-world/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 00:39:32 +0000</pubDate>
		<dc:creator>felixch</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[My name is Felix and this is my first post.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=1&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My name is Felix and this is my first post. </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/felixchu.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/felixchu.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/felixchu.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/felixchu.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/felixchu.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/felixchu.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/felixchu.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/felixchu.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/felixchu.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/felixchu.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/felixchu.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/felixchu.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/felixchu.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/felixchu.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/felixchu.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/felixchu.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=felixchu.wordpress.com&amp;blog=3433941&amp;post=1&amp;subd=felixchu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://felixchu.wordpress.com/2008/04/10/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d8ac70264161540b01ce57a906a75c29?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">felix</media:title>
		</media:content>
	</item>
	</channel>
</rss>
