<?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/"
	>

<channel>
	<title>trentacular &#187; asp.net</title>
	<atom:link href="http://trentacular.com/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://trentacular.com</link>
	<description>Trent Foley's Spectacular Technical Blog</description>
	<lastBuildDate>Thu, 15 Apr 2010 21:32:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Avoiding SOAP Bloat with JSON Services</title>
		<link>http://trentacular.com/2010/04/avoiding-soap-bloat-with-json-services/</link>
		<comments>http://trentacular.com/2010/04/avoiding-soap-bloat-with-json-services/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 20:36:12 +0000</pubDate>
		<dc:creator>Trent</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[wcf]]></category>
		<category><![CDATA[asp.net 3.5]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[visual studio 2010]]></category>
		<category><![CDATA[web services]]></category>

		<guid isPermaLink="false">http://trentacular.com/?p=290</guid>
		<description><![CDATA[In this post I am going to walk through writing and consuming JSON services using ASP.Net, WCF, and jQuery to request the stock price for a company.
Visual Studio 2010 Web Application Project Template Additions

jQuery Intellisense – let Visual Studio write your jQuery for you
AJAX-enabled WCF Service – item template that auto-generates the web.config entries for [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I am going to walk through writing and consuming JSON services using ASP.Net, WCF, and jQuery to request the stock price for a company.</p>
<h4>Visual Studio 2010 Web Application Project Template Additions</h4>
<ul>
<li>jQuery Intellisense – let Visual Studio write your jQuery for you</li>
<li>AJAX-enabled WCF Service – item template that auto-generates the web.config entries for configuring a JSON service to be consumed and proxied by an ASP.Net ScriptManager</li>
<li>Targeted web.config files – easy way to manage different service endpoints for different environments</li>
</ul>
<h4>What is JSON?</h4>
<p>Java Script Object Notation &#8211; JSON is a subset of the object literal notation of JavaScript. Since JSON is a subset of JavaScript, it can be used in the language with no muss or fuss.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> dog <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>color<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;grey&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Spot&quot;</span><span style="color: #339933;">,</span> size<span style="color: #339933;">:</span> <span style="color: #CC0000;">46</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<h4>SOAP Bloat</h4>
<p>SOAP services are extremely verbose. This verbosity enables us to use tools like Visual Studio’s built-in ”Add Service Reference” to auto-generate client proxy classes.  The following examples demonstrate the XML that is used for requesting a stock price and the corresponding response:</p>
<p>Example SOAP Request</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;soap:Envelope</span> <span style="color: #000066;">xmlns:soap</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/12/soap-envelope&quot;</span> <span style="color: #000066;">soap:encodingStyle</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/12/soap-encoding&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;soap:Body</span> <span style="color: #000066;">xmlns:m</span>=<span style="color: #ff0000;">&quot;http://www.example.org/stock&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;m:GetStockPrice<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;m:StockName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>GOOG<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/m:StockName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/m:GetStockPrice<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/soap:Body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/soap:Envelope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Example SOAP Response</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;soap:Envelope</span> <span style="color: #000066;">xmlns:soap</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/12/soap-envelope&quot;</span> <span style="color: #000066;">soap:encodingStyle</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/12/soap-encoding&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;soap:Body</span> <span style="color: #000066;">xmlns:m</span>=<span style="color: #ff0000;">&quot;http://www.example.org/stock&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;m:GetStockPriceResponse<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;m:Price<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>534.5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/m:Price<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/m:GetStockPriceResponse<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/soap:Body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/soap:Envelope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The above example when formatted as JSON is as follows:</p>
<p>GET Request</p>
<pre>ticker=GOOG</pre>
<p>JSON Response</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;d&quot;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">534.5</span><span style="color: #009900;">&#125;</span></pre></div></div>

<h4>JSON Enabling a WCF Service</h4>
<ol>
<li>Using the AJAX-enabled WCF Service item template pretty much does it all.  An additional step can be taken to eliminate the need for the additions to the web.config by configuring the channel factory directly on the service declaration (.svc) file:

<div class="wp_syntax"><div class="code"><pre class="asp" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">@</span> ServiceHost Language<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;C#&quot;</span> Debug<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;true&quot;</span>
    Service<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;Trentacular.JsonWcfDemo.StockPriceService&quot;</span>
    Factory<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;System.ServiceModel.Activation.WebScriptServiceHostFactory&quot;</span>
    CodeBehind<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;StockPriceService.svc.cs&quot;</span> <span style="color: #000000; font-weight: bold;">%&gt;</span></pre></div></div>

</li>
<li>Decorate the operation (service method) with the WebGetAttribute to enable the use of HTTP GET for data retrieval and return the response as JSON :

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>WebGet<span style="color: #000000;">&#40;</span>ResponseFormat <span style="color: #008000;">=</span> WebMessageFormat.<span style="color: #0000FF;">Json</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span></pre></div></div>

</li>
</ol>
<p>Our resulting stock price service’s code behind will look like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">    <span style="color: #000000;">&#91;</span>ServiceContract<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Namespace</span> <span style="color: #008000;">=</span> JsonWcfDemoNamespace.<span style="color: #0000FF;">Value</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> StockPriceService
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)</span>
        <span style="color: #008080; font-style: italic;">// To create an operation that returns XML,</span>
        <span style="color: #008080; font-style: italic;">//     add [WebGet(ResponseFormat=WebMessageFormat.Xml)],</span>
        <span style="color: #008080; font-style: italic;">//     and include the following line in the operation body:</span>
        <span style="color: #008080; font-style: italic;">//         WebOperationContext.Current.OutgoingResponse.ContentType = &quot;text/xml&quot;;</span>
        <span style="color: #000000;">&#91;</span>OperationContract<span style="color: #000000;">&#93;</span>
        <span style="color: #000000;">&#91;</span>WebGet<span style="color: #000000;">&#40;</span>ResponseFormat<span style="color: #008000;">=</span>WebMessageFormat.<span style="color: #0000FF;">Json</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #0600FF;">public</span> StockPrice GetStockPrice<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> ticker<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            ...
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// Add more operations here and mark them with [OperationContract]</span>
    <span style="color: #000000;">&#125;</span></pre></div></div>

<h4>Converting Text to JSON and Back</h4>
<p><strong>eval()</strong> &#8211; invokes the JavaScript compiler. The compiler will correctly parse the text and produce an object structure. The eval function is very fast. However, it can compile and execute any JavaScript program, so there can be security issues.</p>
<p><strong>JSON.parse()</strong> &#8211; To defend against security issues with the eval function, it is preferred to use a JSON parser. A JSON parser will recognize only JSON text, rejecting all scripts. In browsers that provide native JSON support, JSON parsers are also much faster than eval. It is expected that native JSON support will be included in the next ECMAScript standard.</p>
<h4>jQuery’s $.getJSON() Method</h4>
<p>jQuery provides the getJSON method for easily making calls to services providing JSON-formatted responses and performing the JSON conversion.  Its signature is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span> url<span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span> data <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span> callback<span style="color: #009900;">&#40;</span>data<span style="color: #339933;">,</span> textStatus<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span></pre></div></div>

<p>url &#8211; A string containing the URL to which the request is sent.</p>
<p>data &#8211; A map or string that is sent to the server with the request.</p>
<p>callback(data, textStatus) &#8211; A callback function that is executed if the request succeeds.</p>
<p>Consuming our stock price service using the getJSON method will look like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;StockPriceService.svc/GetStockPrice&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> ticker<span style="color: #339933;">:</span> tickerValue <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>data<span style="color: #339933;">,</span> textStatus<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>textStatus <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'success'</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>data.<span style="color: #660066;">d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#stockPricePanel&quot;</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;error&quot;&gt;Error looking up stock price.  Did you enter a valid ticker?&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> stockPrice <span style="color: #339933;">=</span> data.<span style="color: #660066;">d</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> isIncrease <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>stockPrice.<span style="color: #660066;">Delta</span> <span style="color: #339933;">&gt;=</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> deltaStyle <span style="color: #339933;">=</span> isIncrease <span style="color: #339933;">?</span> <span style="color: #3366CC;">'gain'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'loss'</span><span style="color: #339933;">;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#stockPricePanel&quot;</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;price&quot;&gt;'</span> <span style="color: #339933;">+</span> stockPrice.<span style="color: #660066;">Price</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;delta '</span> <span style="color: #339933;">+</span> deltaStyle <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;'</span> <span style="color: #339933;">+</span> stockPrice.<span style="color: #660066;">Delta</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;percent '</span> <span style="color: #339933;">+</span> deltaStyle <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;('</span> <span style="color: #339933;">+</span> stockPrice.<span style="color: #660066;">PercentChange</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'%)&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h4>Working with WCF Serialized JSON Dates</h4>
<p>One caveat when working with JSON is that WCF serializes DateTimes to JSON in the format:</p>
<p>/Date({milliseconds since 01/01/1970}-{time zone})/</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://trentacular.com/wp-content/uploads/2010/04/image.png" border="0" alt="image" width="640" height="188" /><br />
Unfortunately, native JSON conversion does not automatically convert the date string to a JavaScript date object.  The following method shows an example of how to convert a JSON date string to a javascript Date object:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> convertJSONToDate<span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span>json.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\/Date\((.*?)\)\//gi</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;new Date($1)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h4>Download the Demo Application</h4>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://trentacular.com/wp-content/uploads/2010/04/image1.png" border="0" alt="image" width="640" height="195" /><br />
<a href="/wp-content/uploads/2010/04/Trentacular.JsonWcfDemo.zip"><img src="/wp-content/uploads/2010/04/download.png" alt="Download Now" title="Download Now" /></a> <a href="/wp-content/uploads/2010/04/Trentacular.JsonWcfDemo.zip" title="Download Now">Download Now</a></p>
]]></content:encoded>
			<wfw:commentRss>http://trentacular.com/2010/04/avoiding-soap-bloat-with-json-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SharePoint FBA: Basic &#8220;All Authenticated Users&#8221; Role Provider</title>
		<link>http://trentacular.com/2009/12/sharepoint-fba-basic-all-authenticated-users-role-provider/</link>
		<comments>http://trentacular.com/2009/12/sharepoint-fba-basic-all-authenticated-users-role-provider/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 19:22:29 +0000</pubDate>
		<dc:creator>Trent</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[authorization]]></category>
		<category><![CDATA[forms based authentication]]></category>
		<category><![CDATA[role provider]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://trentacular.com/?p=198</guid>
		<description><![CDATA[When managing users and groups within a SharePoint Web application configured to use Windows Integrated Authentication,  there is a convenient &#8220;Add all authenticated users&#8221; link that adds a special Active Directory group &#8211; NT AUTHORITY\authenticated users &#8211; to the Users/Groups People Editor.  This group refers to any non-anonymous user, which if you ask me, seems [...]]]></description>
			<content:encoded><![CDATA[<p>When managing users and groups within a SharePoint Web application configured to use Windows Integrated Authentication,  there is a convenient &#8220;Add all authenticated users&#8221; link that adds a special Active Directory group &#8211; <strong>NT AUTHORITY\authenticated users</strong> &#8211; to the Users/Groups People Editor.  This group refers to any non-anonymous user, which if you ask me, seems like a pretty common group to have around.  However, when working within a SharePoint Web application configured to use Forms Based Authentication (FBA), this convenient group is no longer available.</p>
<p>When using FBA, the only &#8220;non-SharePoint&#8221; groups available to us are the roles exposed by an ASP.Net Role Provider.  If you are already using a custom Role Provider and are not able to make changes to it, then you can stop here.  This post is not for you.  If you are like me though, and are using FBA merely for authentication and are leveraging SharePoint for all authorization, then the single &#8220;All Authenticated Users&#8221; role is all I need from my Role Provider.  As a result, there is no need to use a heavy weight Role Provider (i.e., the SQL Role Provider) to accomplish this, but rather roll your own very dumb role provider.  There is only a single method that you will need to implement &#8211; GetRolesForUser &#8211; in which you can assume the user is already authenticated and always return the &#8220;All Authenticated Users&#8221; role for the user.  Here is the Role Provider I am currently using:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Web.Security</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Trentacular.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">Security</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> SimpleAllAuthenticatedUsersRoleProvider <span style="color: #008000;">:</span> RoleProvider
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">const</span> <span style="color: #FF0000;">string</span> AllAuthenticatedUsersRoleName <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;All Authenticated Users&quot;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">string</span> ApplicationName <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> GetRolesForUser<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> username<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> <span style="color: #008000;">new</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#123;</span> AllAuthenticatedUsersRoleName <span style="color: #000000;">&#125;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080;">#region Methods Not Implemented</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> GetAllRoles<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> NotImplementedException<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">bool</span> IsUserInRole<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> username, <span style="color: #FF0000;">string</span> roleName<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> NotImplementedException<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">bool</span> RoleExists<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> roleName<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> NotImplementedException<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> AddUsersToRoles<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> usernames, <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> roleNames<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> NotImplementedException<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> CreateRole<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> roleName<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> NotImplementedException<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">bool</span> DeleteRole<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> roleName, <span style="color: #FF0000;">bool</span> throwOnPopulatedRole<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> NotImplementedException<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> FindUsersInRole<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> roleName, <span style="color: #FF0000;">string</span> usernameToMatch<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> NotImplementedException<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> GetUsersInRole<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> roleName<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> NotImplementedException<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> RemoveUsersFromRoles<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> usernames, <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> roleNames<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> NotImplementedException<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080;">#endregion</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>After rolling your own role provider, you will need to register it in the web.config inside the &lt;system.web&gt; section as such:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;roleManager</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">defaultProvider</span>=<span style="color: #ff0000;">&quot;SimpleAllAuthenticatedUsersRoleProvider&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;providers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SimpleAllAuthenticatedUsersRoleProvider&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Trentacular.Web.Security.SimpleAllAuthenticatedUsersRoleProvider, Trentacular.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=aaaaaaaaaaaaaaaa&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/providers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/roleManager<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://trentacular.com/2009/12/sharepoint-fba-basic-all-authenticated-users-role-provider/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using jQuery with ASP.Net Demo Web site</title>
		<link>http://trentacular.com/2009/07/using-jquery-with-asp-net-demo-web-site/</link>
		<comments>http://trentacular.com/2009/07/using-jquery-with-asp-net-demo-web-site/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 20:34:14 +0000</pubDate>
		<dc:creator>Trent</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[ajax history]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[facebox]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[modal dialog]]></category>

		<guid isPermaLink="false">http://trentacular.com/?p=150</guid>
		<description><![CDATA[I was recently asked to demonstrate how to use jQuery with ASP.Net, with a focus on AJAX.  So I spent a few hours and cooked up this demo web site.
The Web site demonstrates the following jQuery concepts:

Basic jQuery selectors and API usage
Wiring up javascript event handlers with jQuery
AJAX autocomplete textbox using the Autocomplete plugin
Maintaining AJAX [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently asked to demonstrate how to use jQuery with ASP.Net, with a focus on AJAX.  So I spent a few hours and cooked up this demo web site.</p>
<p>The Web site demonstrates the following jQuery concepts:</p>
<ul>
<li>Basic jQuery selectors and API usage</li>
<li>Wiring up javascript event handlers with jQuery</li>
<li>AJAX autocomplete textbox using the <a href="http://www.pengoworks.com/workshop/jquery/autocomplete.htm">Autocomplete plugin</a></li>
<li>Maintaining AJAX navigation history and state using the <a href="http://www.mikage.to/jquery/jquery_history.html">History plugin</a></li>
<li>Loading dynamic html into a panel using the jQuery.load API function</li>
<li>Loading dynamic html into a modal dialog using the <a href="http://famspam.com/facebox">FaceBox plugin</a></li>
</ul>
<p>The demo could be useful to both someone starting out with jQuery or an old-timer looking for some new AJAX approaches.  Let me know what you think.</p>
<h4>Download</h4>
<p><a href="/wp-content/uploads/2009/07/asp.net-jQuery-demo.zip">asp.net-jQuery-demo.zip</a><br />
(Requires Visual Studio 2008 and the .Net Framework 3.5)</p>
<h4>Preview</h4>
<p><object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/lPvkb_1zJWc&#038;hl=en&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/lPvkb_1zJWc&#038;hl=en&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://trentacular.com/2009/07/using-jquery-with-asp-net-demo-web-site/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>nHibernate in the Enterprise</title>
		<link>http://trentacular.com/2009/04/nhibernate-in-the-enterprise/</link>
		<comments>http://trentacular.com/2009/04/nhibernate-in-the-enterprise/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 16:25:33 +0000</pubDate>
		<dc:creator>Trent</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[enterprise]]></category>
		<category><![CDATA[nHibernate]]></category>

		<guid isPermaLink="false">http://trentacular.com/?p=101</guid>
		<description><![CDATA[I just recently received this response regarding the use of nHibernate within the division of the company I am working with:
 &#8230; [nHibernate] has alot of promise I think but [coorporate] doesn&#8217;t consider it &#8220;stable&#8221; yet &#8230;
Are you kidding me?  Where do these guys get their information?  I guess the Microsoft Entity Framework [...]]]></description>
			<content:encoded><![CDATA[<p>I just recently received this response regarding the use of nHibernate within the division of the company I am working with:</p>
<blockquote><p> &#8230; [nHibernate] has alot of promise I think but [coorporate] doesn&#8217;t consider it &#8220;stable&#8221; yet &#8230;</p></blockquote>
<p>Are you kidding me?  Where do these guys get their information?  I guess the Microsoft Entity Framework is stable enough though.</p>
<p>Lets see, nHibernate is a port of the Java Hibernate Framework which was first released on November 30, 2001 (making it almost 8 years old).  The major 1.2.1 version of nHibernate was released in November 2007, improving on the <em>already stable</em> port of the the Hibernate framework, adapting .Net 2.0 language features.</p>
<p>I began using the Hibernate framework in the Fall of 2005 being introduced to it by my colleague <a href="http://winstonfassett.com/blog/">Winston Fassett</a>.  I switched over to .Net development in the Fall of 2006, and have been using nHibernate from the start.</p>
<p>Having used nHibernate since before the 1.2.1 release, I can safely vouch for its stability and performance &#8230; visit <a href="http://racenation.com">http://racenation.com</a> for an example of my most recent nHibernate project.</p>
<p>I can&#8217;t say that some of the surrounding projects like <a href="http://ayende.com/Blog/archive/2007/03/16/Linq-for-NHibernate.aspx">Linq to nHibernate</a>, although very cool, can be considered stable, but how long does a framework need to be around and used to be considered stable?</p>
]]></content:encoded>
			<wfw:commentRss>http://trentacular.com/2009/04/nhibernate-in-the-enterprise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Great Reads by My Colleague Winston</title>
		<link>http://trentacular.com/2008/10/great-reads-b-my-colleague-winston/</link>
		<comments>http://trentacular.com/2008/10/great-reads-b-my-colleague-winston/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 22:22:28 +0000</pubDate>
		<dc:creator>Trent</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[webforms]]></category>

		<guid isPermaLink="false">http://trentacular.com/?p=48</guid>
		<description><![CDATA[I&#8217;m not sure how much exposure these posts are receiving, so I am posting them here because they are well worth the read:
On the WebForms vs MVC Debate
ASP.NET WebForms: As *Component Frameworks* Go, It’s Pretty Good
Winston Fassett is a previous manager of mine when I was working at ORIX USA, where building rapid applications for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not sure how much exposure these posts are receiving, so I am posting them here because they are well worth the read:</p>
<p id="post-9" class="archive_title"><a href="http://winstonfassett.com/blog/2008/02/06/on-webforms-part-i/">On the WebForms vs MVC Debate</a></p>
<p id="post-14" class="archive_title"><a href="http://winstonfassett.com/blog/2008/02/10/good-stuff-about-webforms/">ASP.NET WebForms: As *Component Frameworks* Go, It’s Pretty Good</a></p>
<p>Winston Fassett is a previous manager of mine when I was working at ORIX USA, where building rapid applications for demanding financial analysts was our focus.  When I made the move to <a href="http://racenation.com">racenation.com</a>, the founder soon after lured Winston to join us, and from the ground up we architected and developed what is <a href="http://racenation.com">racenation.com</a>.  I have learned an immense amount from working with him and can safely say he is the sharpest developer I&#8217;ve been in contact with throughout my career.  Also check out his self-developed mindmapping tool <a href="http://mindtree.winstonfassett.com/wiki/MindTree">MindTree</a>, which I am using extensively for a variety of tasks from meeting notes to project management.</p>
]]></content:encoded>
			<wfw:commentRss>http://trentacular.com/2008/10/great-reads-b-my-colleague-winston/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
