<?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>adam mokan &#187; asp.net</title>
	<atom:link href="http://www.adammokan.com/tag/asp-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adammokan.com</link>
	<description>ramblings of a software developer, mad scientist, geek, and father</description>
	<lastBuildDate>Tue, 22 Nov 2011 19:11:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MVC Mini Profiler</title>
		<link>http://www.adammokan.com/2011/11/14/mvc-mini-profiler/</link>
		<comments>http://www.adammokan.com/2011/11/14/mvc-mini-profiler/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 18:07:37 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[asp.net mvc3]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[dot net]]></category>
		<category><![CDATA[nuget]]></category>
		<category><![CDATA[razor]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[wcf]]></category>
		<category><![CDATA[asp.net mvc 3]]></category>
		<category><![CDATA[mvc-mini-profiler]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/?p=82</guid>
		<description><![CDATA[I&#8217;ve started to use the very helpful Mini-Profiler in my apps and love the base functionality provided and optional approach to profiling specific portions of your application. It&#8217;s worth mentioning that Mini-Profiler is open source and used in production by the folks at StackOverflow, so feel confident that it is a solid assembly with plenty [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started to use the very helpful <a href="http://code.google.com/p/mvc-mini-profiler/" target="_blank">Mini-Profiler</a> in my apps and love the base functionality provided and optional approach to profiling specific portions of your application. It&#8217;s worth mentioning that Mini-Profiler is open source and used in production by the folks at <a href="http://stackoverflow.com" target="_blank">StackOverflow</a>, so feel confident that it is a solid assembly with plenty of options to meet your needs.</p>
<p>For those that haven&#8217;t checked it out, bring MiniProfiler into your application <a href="http://nuget.org/List/Packages/MiniProfiler" target="_blank">via NuGet</a> with a</p>
<pre>Install-Package MiniProfiler</pre>
<p>If you are working in a web project (MVC, WebForms), you simply add the following line of code in your head block <em>AFTER</em> your jQuery reference (this line is formatted as Razor for MVC 3) -</p>
<pre>@MvcMiniProfiler.MiniProfiler.RenderIncludes()</pre>
<p>One thing worth mentioning is that on IE9, I had some issues with the UI of the profiler displaying appropriately. I looked around and found a post mentioning adding the following to your CSS file and sure enough, it fixed my IE9 issue. So, give it a shot if you have any problems displaying the profile on Internet Explorer.</p>
<pre>div.profiler-popup
{
    overflow: visible !important;
}</pre>
<div id="attachment_86" class="wp-caption alignnone" style="width: 310px"><a href="http://www.adammokan.com/wp-content/uploads/2011/11/mini_profiler.png"><img class="size-medium wp-image-86" title="mvc-mini-profiler" src="http://www.adammokan.com/wp-content/uploads/2011/11/mini_profiler-300x93.png" alt="" width="300" height="93" /></a><p class="wp-caption-text">Mini-Profiler UI on a simple ASP.NET MVC 3 page</p></div>
<p>I&#8217;ve had success using this for profiling ASP.NET MVC3 applications as well as Entity Framework 4.2 &#8220;Code First&#8221; queries within the apps, which is great. I still really like the <a href="http://efprof.com/" target="_blank">Entity Framework Profiler</a> tool from Hibernating Rhinos and rely on it heavily, but Mini-Profiler does a good job of showing ORM query issues.</p>
<p>I plan to try this out with some old WCF projects in the near future as well. In the meantime, pop it into one of your development applications and make sure your code is performing how you expect.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2011/11/14/mvc-mini-profiler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slides from my &#8220;Intro to SignalR&#8221; presentation at Desert Code Camp</title>
		<link>http://www.adammokan.com/2011/11/08/intro-to-signalr-slides/</link>
		<comments>http://www.adammokan.com/2011/11/08/intro-to-signalr-slides/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 04:45:36 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[desert code camp 2011.2]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[dot net]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[nuget]]></category>
		<category><![CDATA[presentations]]></category>
		<category><![CDATA[signalr]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[asp.net mvc 3]]></category>
		<category><![CDATA[dcc11]]></category>
		<category><![CDATA[desert code camp]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[long-polling]]></category>
		<category><![CDATA[SignalR]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/?p=84</guid>
		<description><![CDATA[I uploaded the slides from my &#8220;Intro to SignalR&#8221; presentation at Desert Code Camp 2011.2 which was held this past weekend (11/05/2011) at Chandler-Gilbert Community College. I did add some additional bullet points and text content to the slide deck since I&#8217;m not a big fan of standing in front of a bunch of that [...]]]></description>
			<content:encoded><![CDATA[<p>I uploaded the slides from my &#8220;Intro to SignalR&#8221; presentation at Desert Code Camp 2011.2 which was held this past weekend (11/05/2011) at Chandler-Gilbert Community College.</p>
<p>I did add some additional bullet points and text content to the slide deck since I&#8217;m not a big fan of standing in front of a bunch of that during a presentation and would rather talk with the attendees and show some code. Either way, check the slides out if you&#8217;d like.</p>
<p><a href="http://www.slideshare.net/adammokan/introduction-to-signalr-10082193" target="_blank">http://www.slideshare.net/adammokan/introduction-to-signalr-10082193</a></p>
<p>Next up is some tweaks to my samples, which were not cooperating with me so much during my session. I will expose that repo on Github soon and post an update.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2011/11/08/intro-to-signalr-slides/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NuGet.Server sample project</title>
		<link>http://www.adammokan.com/2011/10/12/nuget-server-sample-project/</link>
		<comments>http://www.adammokan.com/2011/10/12/nuget-server-sample-project/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 17:35:26 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[dot net]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[nuget]]></category>
		<category><![CDATA[iis express]]></category>
		<category><![CDATA[nuget.server]]></category>
		<category><![CDATA[vs2010]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/?p=80</guid>
		<description><![CDATA[A couple days ago I mentioned how simple getting an internal Nuget repository via NuGet.Server was. Apparently, it didn&#8217;t go as smooth for others as it did for me based on some replies and DMs. So, I setup a new sample project and pushed it to github for anyone to try. I have succesfully tested [...]]]></description>
			<content:encoded><![CDATA[<p>A couple days ago I mentioned how simple getting an internal Nuget repository via <a href="http://nuget.org/List/Packages/NuGet.Server" target="_blank">NuGet.Server</a> was. Apparently, it didn&#8217;t go as smooth for others as it did for me based on some replies and DMs.</p>
<p>So, I setup a new sample project and pushed it to github for anyone to try. I have succesfully tested this sample in IIS Express as well as IIS 7. Both had no issues after some minor adjustments. For IIS Express I do note some modifications in the README in the github repo that you should take note of. But simply cloning and running should get you going. Be sure, if you are in Visual Studio, that you tell the project to use IIS Express though.</p>
<p>Here is the link to the sample project on github - <a title="github.com/amokan/Nuget.Server-Sample-Project" href="https://github.com/amokan/Nuget.Server-Sample-Project" target="_blank">https://github.com/amokan/Nuget.Server-Sample-Project</a></p>
<p>The basic steps to create the project like I did were:</p>
<ol>
<li>Create a new &#8220;ASP.NET Empty Web Application&#8221; in Visual Studio.</li>
<li>Either use the GUI or NuGet Console to install the <a href="http://nuget.org/List/Packages/NuGet.Server" target="_blank">Nuget.Server</a> package.</li>
<li>Adjust the web.config, as needed.</li>
<li>Profit (or happiness&#8230; i&#8217;m not sure what&#8217;s motivating you here)</li>
</ol>
<div>Enjoy and hopefully this works for someone out there!</div>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2011/10/12/nuget-server-sample-project/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC Controller Navigator</title>
		<link>http://www.adammokan.com/2010/10/06/asp-net-mvc-controller-navigator/</link>
		<comments>http://www.adammokan.com/2010/10/06/asp-net-mvc-controller-navigator/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 18:36:26 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[dot net]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[controllernavigator]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[routing]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/?p=37</guid>
		<description><![CDATA[I have watched a number of developers new to ASP.NET MVC start a new project and have trouble with concepts like routing. The concepts of routing and controllers can be tough to grasp after years of development where you are thinking about a file on disk and you just entered the URL for that file. [...]]]></description>
			<content:encoded><![CDATA[<p>I have watched a number of developers new to ASP.NET MVC start a new project and have trouble with concepts like routing. The concepts of routing and controllers can be tough to grasp after years of development where you are thinking about a file on disk and you just entered the URL for that file. It got me thinking about making life a little easier during the development process when you may not have your navigation plumbing in place and just want to zip through a couple controllers and show someone your app. Phil Haack&#8217;s <a href="http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx">Routing Debugger</a> has always been a great help during development on a site with custom routes and his tool (and source code) gave me a huge head start on what I wanted to do.</p>
<p>So I came up with an assembly I&#8217;m calling &#8220;ControllerNavigator&#8221; for now (<a href="http://github.com/amokan/ControllerNavigator">http://github.com/amokan/ControllerNavigator</a>). I didn&#8217;t spend time to come up with a cool name like the Ruby folks normally do yet. Will have to reference a cult-classic 80s flick or something if I do much more work on it. To use ControllerNavigator (man, I&#8217;m hating the name already), you reference the assembly in your MVC project, and add a line to your Application_Start() in Global.asax.</p>
<pre class="brush: csharp; highlight:[7];">
protected void Application_Start()
{
	AreaRegistration.RegisterAllAreas();

	RegisterRoutes(RouteTable.Routes);

	ControllerNavigator.Navigator.DisplayNavigator(RouteTable.Routes);
}
</pre>
<p>That generates this markup at a custom route, which you could set as the default start page in Visual Studio during development.</p>
<p><a href="http://www.adammokan.com/wp-content/uploads/2010/10/ControllerNavigator.png"><img src="http://www.adammokan.com/wp-content/uploads/2010/10/ControllerNavigator.png" alt="" title="ControllerNavigator" width="794" height="300" class="alignnone size-full wp-image-38" /></a></p>
<p>What happens in DisplayNavigator is some fun C# reflection code that queries your MVC assembly to find all of the controllers, methods in those controllers, and any actionfilters/attributes they have. There are options before calling DisplayNavigator() to filter out certain attributes and also to specify which base class your controllers are inherited from, if different than System.Web.Mvc.Controller. Then, by stealing some of Mr Haack&#8217;s code from his RouteDebugger, it takes the data and generates a custom route (defaults to &#8220;/Navigator&#8221;) that shows a table listing your controllers, methods, method return types (ActionMethod, JsonMethod, etc), and finally a hyperlink that will launch that route in a new window.</p>
<p>I have some more ideas to make this more useful, which are listed on <a href="http://github.com/amokan/ControllerNavigator">the GitHub page</a>, but in the meantime feel free to check it out or steal the code to make your own version. If you have questions or comments, hit me up on <a href="http://twitter.com/adammokan">twitter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2010/10/06/asp-net-mvc-controller-navigator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ELMAH = awesome</title>
		<link>http://www.adammokan.com/2009/12/02/elmah-awesome/</link>
		<comments>http://www.adammokan.com/2009/12/02/elmah-awesome/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 07:00:00 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[elmah]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/2009/12/02/elmah-awesome/</guid>
		<description><![CDATA[So, I&#39;m a bit late to the game on this. But ELMAH (Error Logging Modules and Handlers) is awesome. Basically just drop the dll in your bin folder on your project and adjust your web.config. It handles your error handling and logging automatically. Very slick. I got it in place today on a couple apps [...]]]></description>
			<content:encoded><![CDATA[<p>So, I&#39;m a bit late to the game on this. But <a href="http://elmah.googlecode.com/">ELMAH</a> (Error Logging Modules and Handlers) is awesome.<br />
Basically just drop the dll in your bin folder on your project and adjust your web.config. It handles your error handling and logging automatically. Very slick.<br />
I got it in place today on a couple apps (ASP.NET webforms and ASP.NET MVC 2) and it writes to a SQL database (one of many options for logging).<br />
But, as with most things I mess with, its not enough (and not its own fault). I have an internal system already in place for tracking and managing our applications. I setup the ELMAH table in the same database as my tracking app and want to have a way to tie them together. So, now I am modifying the Error.cs class in the Elmah source to allow me to put the ApplicationID in the web.config so I can query the Elmah error table in relation to my existing application metrics.<br />
I highly recommend checking this little utility out if you&#39;re doing .NET development.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2009/12/02/elmah-awesome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery autocomplete plugin with ASMX web service and JSON</title>
		<link>http://www.adammokan.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/</link>
		<comments>http://www.adammokan.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 07:00:00 +0000</pubDate>
		<dc:creator>adam.mokan</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[soa]]></category>
		<category><![CDATA[asmx]]></category>
		<category><![CDATA[autocomplete]]></category>

		<guid isPermaLink="false">http://www.adammokan.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/</guid>
		<description><![CDATA[I&#8217;m trying to find more reasons to switch a lot of my js/ajax ui over to jQuery recently. This is due to my excursions into Rails and Sinatra outside of work, and also because I feel like some of the MS Ajax Toolkit extenders seem to be bloated at times. I also figure that since [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to find more reasons to switch a lot of my js/ajax ui over to jQuery recently. This is due to my excursions into Rails and Sinatra outside of work, and also because I feel like some of the MS Ajax Toolkit extenders seem to be bloated at times. I also figure that since I intend to dip my feet more into the ASP.NET MVC framework, jQuery seems to be very standard there.&nbsp;</p>
<p>That brings me to (one of) the jQuery Autocomplete plugins. I need this functionality in an ASP.NET webforms application and wanted to give it a shot. I started messing with &#8220;jQuery Autocomplete plugin 1.1&#8243; by Jörn Zaefferer. You can find the code and info at&nbsp;<a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/">http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/</a>.&nbsp;</p>
<p>I&#8217;m mostly interested in doing an autocomplete via a remote web service call that returns json data. The example in the zip file includes a little php page that just responds to a HTTP-GET and spits out some hard-coded json. I&#8217;m working in .NET, so I made a simple ASMX web service to query my database and return a DataTable as json. (Note &#8211; There are isues with the built-in serializer to return a DataTable as json. A google search will find you a number of functions or alternate ways to generate a json string from a DataTable.)&nbsp;
</p>
<p>Right away, I found I was having problems with the autocomplete in this environment. First off, you have the whole issue with ASMX web methods only accepting a POST by default. This is easy to change, but not advised. You can find info on that issue here &#8211; <a href="http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/">http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/</a> and some other good info here &#8211; <a href="http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/">http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/</a>&nbsp;
</p>
<p>You&#8217;ll also notice in the above blog links that there can often be issues when POST-ing to a web method with encoding set to json, that you will need to pass your json params as a string. If you&#8217;re using something like Firebug to watch your ajax posts, you&#8217;ll catch this right away.&nbsp;
</p>
<p>But the main issue for me were&nbsp;the assumptions that the autocomplete plugin makes. It, by default, will only do a HTTP-GET. You can use the $.ajaxSetup in jQuery to set your future ajax calls to a default, but I wanted the ability to make this decision when calling the autocomplete plugin.&nbsp;
</p>
<p>I made these changes to jquery.autocomplete.js in the $.ajax section :</p>
<pre class="brush: js; highlight:[7,8,9,10];">
$.ajax({
// try to leverage ajaxQueue plugin to abort previous requests
mode: "abort",
// limit abortion to this input
port: "autocomplete" + input.name,
dataType: options.dataType,
//setup new options for asmx - amokan
type: options.httpMethod,
contentType: options.contentType,
//end new options - amokan
url: options.url,
</pre>
<p>This allows me to now handle my client side code a little better.</p>
<pre class="brush: js; highlight:[5,6];">
$("#task").autocomplete(
"http://somecomputername/jsonServiceTest/Testing.asmx/GetSomeDataNoParam",
{
dataType: 'json',
httpMethod: 'POST',
contentType: 'application/json; charset=utf-8',
max: 100,
scroll: true,
matchContains: true,
minChars: 3,
parse: function(data) {
var rows = new Array();
//your parsing logic
},
formatItem: function(row, i, n) {
//do something
},
width: 260
}
);
</pre>
<p>I&#8217;m still working on cleaning up the data parameter section of the plugin a bit before I post the full code.<br />
If you&#8217;re curious, here is my ASMX method. Be sure to add the [ScriptService] attribute to your class in the ASMX file so it can handle AJAX properly. If you are using an older .NET without the System.Web.Script.Services namespace, this will not work for you. Note that the parameters &#8220;q&#8221; and &#8220;limit&#8221; are sent automatically by the autocomplete plugin. &#8220;Q&#8221; is the string currently typed into the text control so you can filter your query based on what the user has typed and &#8220;limit&#8221; is the max number of rows. Obviously, its up to you to implement these in your query if you chose to. &nbsp;</p>
<pre class="brush: csharp">
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public string GetSomeDataNoParam(string q, int limit)
{
DataTable dtSomething;
//connect to db, do your exception handling, etc
dtSomething = //your DAL or whatever you use
//use my method to parse the datatable into json
return GetJSONString(dtSomething);
}
</pre>
<p>Hope this helps a bit and I will be sure to upload some more code as I get this working a bit smoother in my environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adammokan.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

