<?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>blog.dervalp.com &#187; MVC</title>
	<atom:link href="http://blog.dervalp.com/tag/mvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dervalp.com</link>
	<description>Think before Programming (Public learning)</description>
	<lastBuildDate>Sat, 20 Mar 2010 22:22:42 +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>ASP.NET MVC : Url Helper Extension CSS, Javascript, Picture</title>
		<link>http://blog.dervalp.com/2009/05/29/aspnet-mvc-url-helper-extension-css-javascript-picture/</link>
		<comments>http://blog.dervalp.com/2009/05/29/aspnet-mvc-url-helper-extension-css-javascript-picture/#comments</comments>
		<pubDate>Fri, 29 May 2009 20:16:56 +0000</pubDate>
		<dc:creator>dervalp</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Url]]></category>

		<guid isPermaLink="false">http://blog.dervalp.com/?p=303</guid>
		<description><![CDATA[Here a url helper, maybe it can interests you :


public static class UrlHelperExtension
{
public static string Image(this UrlHelper helper, string fileName)
{
return helper.Content(string.Format(&#34;~/Content/Images/{0}&#34;,fileName));
}

public static string Stylesheet(this UrlHelper helper, string fileName)
{
return helper.Content(string.Format(&#34;~/Content/Css/{0}.css&#34;,fileName));
}

public static string Javascript(this UrlHelper helper, string fileName)
{
return helper.Content(string.Format(&#34;~/Content/Scripts/{0}.js&#34;, fileName));
}
}

And here is how I use it :
For CSS :


&#60;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;&#60;%= Url.Stylesheet(&#34;reset&#34;) %&#62;&#34; media=&#34;all&#34; /&#62;

For javascript


&#60;script [...]]]></description>
			<content:encoded><![CDATA[<p>Here a url helper, maybe it can interests you :</p>
<pre class="brush: c;">

public static class UrlHelperExtension
{
public static string Image(this UrlHelper helper, string fileName)
{
return helper.Content(string.Format(&quot;~/Content/Images/{0}&quot;,fileName));
}

public static string Stylesheet(this UrlHelper helper, string fileName)
{
return helper.Content(string.Format(&quot;~/Content/Css/{0}.css&quot;,fileName));
}

public static string Javascript(this UrlHelper helper, string fileName)
{
return helper.Content(string.Format(&quot;~/Content/Scripts/{0}.js&quot;, fileName));
}
}
</pre>
<p>And here is how I use it :</p>
<p>For CSS :</p>
<pre class="brush: html;">

&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;&lt;%= Url.Stylesheet(&quot;reset&quot;) %&gt;&quot; media=&quot;all&quot; /&gt;
</pre>
<p>For javascript</p>
<pre class="brush: html;">

&lt;script src=&quot;&lt;%= Url.Javascript(&quot;jquery-1.3.2.min&quot;) %&gt;&quot; type=&quot;text/javascript&quot; language=&quot;javascript&quot;&gt;&lt;/script&gt;
</pre>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d303').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d303" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.dervalp.com/2009/05/29/aspnet-mvc-url-helper-extension-css-javascript-picture/&amp;title=ASP.NET+MVC+%3A+Url+Helper+Extension+CSS%2C+Javascript%2C+Picture" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://blog.dervalp.com/2009/05/29/aspnet-mvc-url-helper-extension-css-javascript-picture/&amp;title=ASP.NET+MVC+%3A+Url+Helper+Extension+CSS%2C+Javascript%2C+Picture" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://blog.dervalp.com/2009/05/29/aspnet-mvc-url-helper-extension-css-javascript-picture/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://blog.dervalp.com/2009/05/29/aspnet-mvc-url-helper-extension-css-javascript-picture/&amp;title=ASP.NET+MVC+%3A+Url+Helper+Extension+CSS%2C+Javascript%2C+Picture" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://blog.dervalp.com/2009/05/29/aspnet-mvc-url-helper-extension-css-javascript-picture/&amp;title=ASP.NET+MVC+%3A+Url+Helper+Extension+CSS%2C+Javascript%2C+Picture" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://blog.dervalp.com/2009/05/29/aspnet-mvc-url-helper-extension-css-javascript-picture/&amp;title=ASP.NET+MVC+%3A+Url+Helper+Extension+CSS%2C+Javascript%2C+Picture" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+ASP.NET+MVC+%3A+Url+Helper+Extension+CSS%2C+Javascript%2C+Picture+@+http://blog.dervalp.com/2009/05/29/aspnet-mvc-url-helper-extension-css-javascript-picture/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://blog.dervalp.com/2009/05/29/aspnet-mvc-url-helper-extension-css-javascript-picture/&amp;t=ASP.NET+MVC+%3A+Url+Helper+Extension+CSS%2C+Javascript%2C+Picture" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d303').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d303').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.dervalp.com/2009/05/29/aspnet-mvc-url-helper-extension-css-javascript-picture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kiwi MVC.NET : Why this, why that ? I explain my architecture choices Part 5 [source on codeplex]</title>
		<link>http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/</link>
		<comments>http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/#comments</comments>
		<pubDate>Fri, 29 May 2009 18:26:39 +0000</pubDate>
		<dc:creator>dervalp</dc:creator>
				<category><![CDATA[Kiwi MVC]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVC.NET]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://blog.dervalp.com/?p=283</guid>
		<description><![CDATA[So, I work hard these days to  finish my data access. I would like to explain you how I see application&#8217;s design.
As I told you before, I want to separate my application in 3 parts. I know that architecture could be discussed but I would make this point clear, it should be &#8220;re-factored&#8221;. Anyway, for [...]]]></description>
			<content:encoded><![CDATA[<p>So, I work hard these days to  finish my data access. I would like to explain you how I see application&#8217;s design.</p>
<p>As I told you before, I want to separate my application in 3 parts. I know that architecture could be discussed but I would make this point clear, it should be &#8220;re-factored&#8221;. Anyway, for the moment, I think it is enough flexible for what I want to do <span style="text-decoration: underline;">NOW</span>.</p>
<p>Here is a reminder of my layers:</p>
<ul>
<li>The Web application which will be the view of my application.</li>
</ul>
<ul>
<li>The controller with all my business logic embedded in a library Service.</li>
</ul>
<ul>
<li>The model library which will contain my models, my data access (repository) and all my filter static classes.</li>
</ul>
<h2><span id="more-283"></span></h2>
<p>To improve my explanations, I hand draw a little pseudo UML diagram :</p>
<p><img class="alignnone size-full wp-image-287" title="kiwi_mvc_pseudo_uml" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_mvc_pseudo_uml.jpg" alt="kiwi_mvc_pseudo_uml" width="805" height="626" /></p>
<p>What I want it is to keep as much as I can the &#8220;Soc&#8221; (separation of concern). My service should make what a service should do and if I want to change my repository with a Oracle one, I could change it only by modifying the instantiation of my service (with DI for the future). I want to keep that &#8220;philosophy&#8221; all along the development but philosophy is not obligation.</p>
<p>In the same way, you&#8217;ve certainly noticed that I often return an IQueryable for my &#8220;get&#8221; method (see listing 1). I know this should be better to return a List type cause it is a more &#8220;standard&#8221; and you do not have to use the Linq library. Nevertheless I think I will keep it. I do not want to call to often the .IEnumerable function and also it will be easier to use my filter classes.</p>
<p>As the only developer for this application, I assume my choices. <img src='http://blog.dervalp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  If you have remarks about this, please leave a comment.</p>
<p>Listing 1 : Example of the getPages method who retreive all the page from my db</p>
<pre class="brush: c;">

public IQueryable&lt;Page&gt; getPages()
{

return from p in _db.Posts
where p.Type == &quot;Page&quot;
let lp = getLocalizedPages(p.PostID)
select new Page
{
PageID = p.PostID,
Author = p.Author,
Date = p.Date,
PageLozalized = new LazyList&lt;PageLocalized&gt;(lp),
ModifiedDate = p.ModifiedDate,
Password = p.Password ?? string.Empty,
Permalink = p.Permalink,
Status = p.PostStatusID,
Version = p.RevisionOf

};
}

private IQueryable&lt;PageLocalized&gt; getLocalizedPages(int postID)
{
return from lp in _db.PostCultureDetails
where lp.PostID == postID
select new PageLocalized()
{
Description = lp.Excerpt,
Text = lp.Text,
Title = lp.Title,
LanguageCode = (from culture in _db.Cultures
where culture.CultureID == lp.CultureID
select culture.LanguageCode).SingleOrDefault()

};

}
</pre>
<p><strong>Why I did not use Entity framework ?</strong> I hate when the framework decide for me which object I should use. Also, the time I would spend to make it work as I want is doubtless longer than the time I wrote my custom Linq to Sql Class. Entity framework could be great for simple application but for an application who will grow in the future (as I expect Kiwi will do) I do not think it&#8217;s a good choice.</p>
<p><strong>Why I did not use NHibernate ? </strong>I could have chosen NHibernate, but I absolutely wanted to play with Linq. Also, maybe in the future I could make the data access with it and compare what&#8217;s better for my application. Anyway, this is not the time to do this.</p>
<p>If you have other questions like this, please, do not hesitate.</p>
<p><strong>And now the service :<br />
</strong></p>
<p>As I mentioned, my data access is almost finished (for the moment). I am going to create the services I need for my application. Evidently, always in a TDD approach.</p>
<p><strong>Kiwi Part 4 was bullshit :</strong></p>
<p>Maybe it was but the aim of that post was to show you how to start with TDD. And I know that I was going in front of a wall. Indeed, I had an empty db and the post object was the most connected object. As you know in TDD, you write a test, you write <span style="text-decoration: underline;">some code</span>. I realized that I should have written a lot (before creating the &#8220;SaveFunction&#8221; for it). I needed the category object, the comment object,&#8230; Thus, I begin to create a save function for the category object (alway with a tdd style).</p>
<p>Create the test :</p>
<pre class="brush: text;">
//Spike Test !!!
[TestMethod]
public void SqlPostRepositoryTest_can_add_category()
{

Category category = new Category();
category.CreatedDate = DateTime.Now;
category.CategoryParentID = 0;
var categoryEn = new CategoryLocalized() {Description = &quot;This is a test&quot;, Value = &quot;Software Development&quot;, LangageCode = &quot;EN&quot;};
var categoryFR = new CategoryLocalized() { Description = &quot;Ceci est un test&quot;, Value = &quot;Développement Logiciel&quot;, LangageCode = &quot;FR&quot; };

var list = new LazyList&lt;CategoryLocalized&gt;();
list.Add(categoryEn);
list.Add(categoryFR);

category.LocalizedCategory = list;

_repository.Save(category);

Assert.IsNotNull(category);

}
</pre>
<p>And after the function I need :</p>
<pre class="brush: c;">

//save or add a category

public void Save (Category category)
{
var dbCategory = (from c in _db.Categories
where c.CategoryID == category.CategoryID
select c).SingleOrDefault();
if(dbCategory == null)
{
dbCategory = new SqlRepository.Category();
dbCategory.CreatedDate = DateTime.Now;
dbCategory.ParentID = category.CategoryParentID;
//commit the change to have the id and insert the culture
_db.Categories.InsertOnSubmit(dbCategory);
_db.SubmitChanges();

//foreach culture we have in the objec we add it in the table CategoryCultureDetail
foreach (CategoryLocalized item in category.LocalizedCategory)
{
var dbitem = new CategoryCultureDetail();
//some Object to DB
dbitem.CategoryID = dbCategory.CategoryID;
dbitem.Description = item.Description;
dbitem.Value = item.Value;
dbitem.CultureID =
(from culture in _db.Cultures
where culture.LanguageCode == item.LangageCode
select culture.CultureID).SingleOrDefault();
dbCategory.CategoryCultureDetails.Add(dbitem);
_db.SubmitChanges();
}

}
else
{

foreach (CategoryLocalized item in category.LocalizedCategory)
{
var thisCategoryLocalized = (from cn in _db.CategoryCultureDetails
where cn.CategoryID == category.CategoryID
where cn.CultureID ==   (from culture in _db.Cultures
where culture.LanguageCode == item.LangageCode
select culture.CultureID).SingleOrDefault()
select cn).SingleOrDefault();
thisCategoryLocalized.Description = item.Description;
thisCategoryLocalized.Value = item.Value;
_db.CategoryCultureDetails.InsertOnSubmit(thisCategoryLocalized);
_db.SubmitChanges();

}
}
}
</pre>
<p>Of course, you see the &#8220;final&#8221; result. To have that, I went by little piece of code. Test, write, build, test, write, build, test &#8230;</p>
<p>I also know the test you see above is not a unit test, it is more an integration test or a spike test and it will be deleted or commented in the future.</p>
<p>But the name is <span style="text-decoration: underline;">test driven </span>design and not &#8220;make pure unit test&#8221; design.</p>
<p>NOTE : I know I am saying that each time I post but I will try to add the source code in my codeplex project this afternoon.</p>
<p>UPDATE  : I put the source on code plex, if you would like to see it : http://dervalp.codeplex.com/</p>
<p>I have some troubles with codeplex, I will check this out tomorrow cause I am a bit tired today.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d283').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d283" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;title=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;title=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;title=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;title=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;title=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D+@+http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;t=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d283').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d283').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kiwi MVC.NET : Authentication Layer, introduction Part2</title>
		<link>http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/</link>
		<comments>http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/#comments</comments>
		<pubDate>Thu, 14 May 2009 12:47:20 +0000</pubDate>
		<dc:creator>dervalp</dc:creator>
				<category><![CDATA[Kiwi MVC]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Membership]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Provider]]></category>
		<category><![CDATA[Role]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://blog.dervalp.com/?p=100</guid>
		<description><![CDATA[I know it is a bit weird to begin a CMS application by implementing a Membership system but the simple raison why I start up with that is because I needed for my work (as you can see in my previous post ).
Too often, I saw developers rewriting their own membership system in place to [...]]]></description>
			<content:encoded><![CDATA[<p>I know it is a bit weird to begin a CMS application by implementing a Membership system but the simple raison why I start up with that is because I needed for my work (as you can see in <a href="http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%C2%BB-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/" target="_blank">my previous post</a> ).</p>
<p>Too often, I saw developers rewriting their own membership system in place to use what the framework (no matter which one) can offer.</p>
<h2><span id="more-100"></span></h2>
<p>It is the main raison why I choose to implement the ASP.NET Membership system in Kiwi.  It has a lot of interesting functionalities but on the other hand it is like riding a big monster.  Thus, I am going to use it as pluggableas as I can do.</p>
<h2>The User Object :</h2>
<p>Today, creating an object called User is being strange. If you want to choose the OOP way, a user is often too generic. If you developed an e-commerce, you will certainly choose customer in place of user. But a customer and an admin can login in your system, so are-you going to create two objects? One called “customer” and the other called “vip”? That sounds weird no?</p>
<p>Here is my point of view. A membership system is for me an additional layer you can implement (or not). It is not the hearth of your application; it is just a security layer. That why I am going to use it without any &#8220;User&#8221; object.  I saw 3 mains services that a Membership system could offer :</p>
<ul>
<li> authentication (who is this guy)</li>
<li>personalization (what the guy like)</li>
<li>authorization (what the guy can do)</li>
</ul>
<h2>Sql membership :</h2>
<p>We saw in one of <a href="http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%C2%BB-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/" target="_blank">my previous post</a> that ASP.NET has 2 differents way to manage the membership layer. There we saw the active directory membership provider. Today, we will use the SqlMembershipProvider.</p>
<p>First, to use Sql membership you need a sql server with a database up. Therefore, I went to the Microsoft website to download Sql Server 2008 express and I installed it.</p>
<p>I create an empty db called Kiwi.</p>
<p>Then in the folder &#8220;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727&#8243;, I execute the aspnet_regsql.exe and provide the right information to allow the connection to the database. Finish the setup and let’s take a look on the database called Kiwi:</p>
<p><img class="alignnone size-full wp-image-105" title="kiwi_part2_1" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_1.jpg" alt="kiwi_part2_1" width="413" height="488" /></p>
<p>Now, I configure the Webconfig to use the SqlMemberShipProvider with my application.<br />
Here is the connection string I added to my webconfig file:</p>
<p><img class="alignnone size-full wp-image-107" title="kiwi_part2_2" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_2.jpg" alt="kiwi_part2_2" width="604" height="100" /></p>
<p>To test if everything works well,</p>
<p>Change the name of the connection string under membership to make the connection with your db.</p>
<p><img class="alignnone size-full wp-image-108" title="kiwi_part2_3" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_3.jpg" alt="kiwi_part2_3" width="590" height="336" /></p>
<p>Now make a test, go to the ASP.NET configuration when you are on your MVC.WEB in your website.</p>
<p><img class="alignnone size-full wp-image-109" title="kiwi_part2_4" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_4.jpg" alt="kiwi_part2_4" width="243" height="445" /></p>
<p>You will enter in the Web Site Administation Tool :</p>
<p><img class="alignnone size-full wp-image-110" title="kiwi_part2_5" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_5.jpg" alt="kiwi_part2_5" width="628" height="381" /></p>
<p>If you click on Security you will access a page where you can manage the users, the roles and the access rules.<br />
For the test, click on the “Create User” link and create one :<br />
<img class="alignnone size-full wp-image-111" title="kiwi_part2_6" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_6.jpg" alt="kiwi_part2_6" width="570" height="308" /></p>
<p>Create the user and go to the server explorer on your Visual Studio. If you do not have a connection to your db yet in server explorer, add it.</p>
<p><img class="alignnone size-full wp-image-112" title="kiwi_part2_7" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_7.jpg" alt="kiwi_part2_7" width="347" height="508" /></p>
<p>On the table aspnet_Users, right-click on Show Table Data and you will see the user you created above.</p>
<p><img class="alignnone size-full wp-image-113" title="kiwi_part2_8" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_8.jpg" alt="kiwi_part2_8" width="628" height="62" /></p>
<p>Cool stuff isn’t it ?<br />
Now we have a db called Kiwi with some tables created by the .NET framwork.<br />
The web application can connect to the Kiwi database and you are now able to manage user with the ASP.NET administation tools.</p>
<p>In the next post : I will begin to code with the Test driven design approach. I will create the different layer we need in our repository to make the authentication working.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d100').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d100" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;title=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;title=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;title=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;title=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;title=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2+@+http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;t=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d100').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d100').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
