<?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 of developer Mikkel Ovesen &#187; asp.net</title>
	<atom:link href="http://blog.ovesens.net/tag/asp-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ovesens.net</link>
	<description>My thoughts, stuff I need to remember or things I just want to share with the world</description>
	<lastBuildDate>Thu, 19 Jan 2012 11:55:29 +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>My attempts at installing Umbraco via NuGet</title>
		<link>http://blog.ovesens.net/2011/11/my-attempts-at-installing-umbraco-via-nuget/</link>
		<comments>http://blog.ovesens.net/2011/11/my-attempts-at-installing-umbraco-via-nuget/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 13:19:20 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[nuget]]></category>
		<category><![CDATA[umbraco]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[vs]]></category>
		<category><![CDATA[vs2010]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=461</guid>
		<description><![CDATA[I often use Umbraco as a CMS for my web projects, and NuGet for referencing other libraries. This made me wonder whether Umbraco could be deployed via Nuget. The short answer is, it is possible, but it does not work &#8230; <a href="http://blog.ovesens.net/2011/11/my-attempts-at-installing-umbraco-via-nuget/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I often use <a href="http://umbraco.com/">Umbraco</a> as a CMS for my web projects, and NuGet for referencing other libraries. This made me wonder whether Umbraco could be deployed via Nuget. The short answer is, it is possible, but it does not work very well. Here is my experience.</p>
<p>I started to read the <a href="http://docs.nuget.org/">NuGet docs</a> to figure out what a NuGet package actually is.</p>
<h2>NuGet package</h2>
<p>A NuGet package is a file that makes it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework. A NuGet package is comprised by these three things:</p>
<ul>
<li><strong>tools</strong> &#8211; The tools folder of a package is for powershell scripts and programs accessible from the Package Manager Console. After the folder is copied to the target project, it is added to the `$env:Path (PATH) environment variable.</li>
<li><strong>lib</strong> &#8211; Assemblies (.dll files) in the lib folder are added as assembly references when the package is installed.</li>
<li><strong>content</strong> &#8211; Files in the content folder are copied to the root of your application when the package is installed.</li>
</ul>
<div><em><span style="font-size: small;"><span class="Apple-style-span" style="line-height: 24px;">The above is from the <a href="http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package">NuGet docs</a>.</span></span></em></div>
<p>The documentation also indicate that NuGet was not designed for a project like Umbraco with so many files and such a complex web.config file. But I wanted to try and see how and if it was actually possible.</p>
<h2>The strategy</h2>
<p>The Umbraco project consists of libraries/assemblies and content, so it should be rather easy to create the NuGet package.</p>
<p>The first step was to download Umbraco 4.7.1 and go through the required assemblies and web.config. Initially I located assemblies that could already be found on NuGet and added these dependencies to the NuGet package. It later showed, that there would be versioning problems which I was not able to fix.</p>
<p>So instead of using dependencies to other NuGet packages as NuGet was actually intended, I  just added all the assemblies released with Umbraco 4.7.1.</p>
<h2>Assemblies</h2>
<p>The assemblies that gave me the most trouble was ClientDependency and ICharpCode.SharpZipLib.</p>
<p>ClientDependency was actually already in the NuGet feed, but the configuration transformation made from that NuGet package combined with the web.config transformation from the Umbraco package, yilded an invalid web.config file.  ClientDependency was therefor provided as an assembly directly from the Umbraco package and not as an external dependency.</p>
<p>The assembly ICSharpCode.SharpZipLib was also found in the NuGet feed, but Umbraco 4.7.1 required a specific version (0.85.5.452) that NuGet could not provide, and this assembly was as such also added as a part of the Umbraco package.</p>
<h2>Web.config</h2>
<p>The web.config configuration file for Umbraco is long and rather complex, and that makes merging of multiple web.config files difficult. The configuration transformation features in NuGet are limited, so you should expect problems when adding the Umbraco package to an existing website. The best results I achieved was when the package was added to an empty website or web application.</p>
<p>But even though a web.config file is almost empty, you should still prepare for some clean up.</p>
<h2>Content</h2>
<p>The <a href="http://umbraco.codeplex.com/releases/view/73692">Umbraco 4.7.1 binary release</a> containes more than 1500 files. NuGet was not designed for this number of files and does not handle it very well. A complete package installation can take up to 5-10 min. depending on you machine and SSD/HDD configuration.</p>
<h2>Example</h2>
<p>The following describes the steps I used to run the Umbraco NuGet package against a web application project and the problems that arose.</p>
<p>1. Open Visual Studio 2010 and create an empty C# web application project</p>
<p>2. Open the NuGet Package Manager Console</p>
<p>3. Write:</p>
<pre>Install-Package "Umbraco" -Source "c:\[NuGetPackageFolder]"</pre>
<p><em>NuGetPackageFolder: Replace with the path to the folder containing the Umbraco.4.7.1.nupkg file. <strong>Important do not give the full path to the file, just the folder</strong></em></p>
<p>4. Hit [ENTER] and wait for NuGet to do its work</p>
<p>5. Wait for the following two messages:</p>
<pre>Successfully installed 'Umbraco 4.7.1'.
Successfully added 'Umbraco 4.7.1' to WebApplication1.</pre>
<p>6. Compile and receive an error from web.config. (Multiple System.Web -&gt; Compilation sections are present)</p>
<p>7. Remove the first and compile and run again</p>
<pre class="brush: xml;">&lt;compilation debug="true" targetFramework="4.0" /&gt;</pre>
<p>8. At this point everything worked and I was able to follow the usual Umbraco installation steps <img src='http://blog.ovesens.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>Conclusion</h2>
<p>Umbraco is a fantastic CMS and NuGet is very cool, but together is not a good idea.</p>
<p>My goal was to find a way for installing Umbraco to a web project via NuGet, and that is not impossible, but I would not recommend it. I find it a lot easier to simply download the Umbraco released ZIP, and then extract and drag all files to my web application project. So that is what I will do <img src='http://blog.ovesens.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>But if you still wants the Umbraco NuGet file, you can download it <a href="/wp-content\uploads/2011/11/Umbraco.4.7.1.nupkg.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2011/11/my-attempts-at-installing-umbraco-via-nuget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Async Httphandlers in ASP.NET</title>
		<link>http://blog.ovesens.net/2010/05/async-httphandlers-in-asp-net/</link>
		<comments>http://blog.ovesens.net/2010/05/async-httphandlers-in-asp-net/#comments</comments>
		<pubDate>Thu, 27 May 2010 11:57:44 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[async]]></category>
		<category><![CDATA[httphandler]]></category>
		<category><![CDATA[thread]]></category>
		<category><![CDATA[threading]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=235</guid>
		<description><![CDATA[What is the correct way to create a httphandler that potentially can take time and resources to complete. Well this article explains it very well: http://msdn.microsoft.com/en-us/magazine/cc164128.aspx If you don&#8217;t want to read all, you find the best solution in the &#8230; <a href="http://blog.ovesens.net/2010/05/async-httphandlers-in-asp-net/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>What is the correct way to create a httphandler that potentially can take time and resources to complete.</p>
<p>Well this article explains it very well:<br />
<a href="http://msdn.microsoft.com/en-us/magazine/cc164128.aspx" target="_blank"> http://msdn.microsoft.com/en-us/magazine/cc164128.aspx</a></p>
<p>If you don&#8217;t want to read all, you find the best solution in the bottom of the article.</p>
<p>But you can also find the code here, download this libraryÂ <a href="http://blog.ovesens.net/wp-content/uploads/2010/05/threadpool.zip">C# Threadpool</a>.</p>
<h2>AsyncRequest</h2>
<pre id="ctl00_MTContentSelector1_mainContentContainer_ctl33_ctl00_ctl00_code">class AsyncRequest
{
  private AsyncRequestState _asyncRequestState;

  public AsyncRequest(AsyncRequestState ars)
  {
    _asyncRequestState = ars;
  }

  public void ProcessRequest()
  {
    // This is where the non-cpu-bound activity would take place, such as
    // accessing a Web Service, polling a slow piece of hardware, or
    // performing a lengthy database operation. I put the thread to sleep
    // for two seconds to simulate a lengthy operation.
    Thread.Sleep(2000);

    _asyncRequestState._ctx.Response.Output.Write(
            "AsyncThread, {0}",
            AppDomain.GetCurrentThreadId());

    // tell asp.net I am finished processing this request
    _asyncRequestState.CompleteRequest();
  }
}</pre>
<h2>AsyncHandler</h2>
<pre id="ctl00_MTContentSelector1_mainContentContainer_ctl35_ctl00_ctl00_code">namespace EssentialAspDotNet.HttpPipeline
{
  // AsyncRequestState and AsyncRequest remain the same
  // as in the previous example

  public class AsyncHandler : IHttpAsyncHandler
  {
    static DevelopMentor.ThreadPool _threadPool;

    static AsyncHandler()
    {
      _threadPool =
        new DevelopMentor.ThreadPool(2, 25, "AsyncPool");
      _threadPool.PropogateCallContext = true;
      _threadPool.PropogateThreadPrincipal = true;
      _threadPool.PropogateHttpContext = true;
      _threadPool.Start();
    }

    public void ProcessRequest(HttpContext ctx)
    {
     // not used
    }

    public bool IsReusable
    {
      get { return false;}
    }

    public IAsyncResult BeginProcessRequest(HttpContext ctx,
                     AsyncCallback cb, object obj)
    {
      AsyncRequestState reqState =
                     new AsyncRequestState(ctx, cb, obj);
      _threadPool.PostRequest(
                     new DevelopMentor.WorkRequestDelegate(ProcessRequest),
                     reqState);

      return reqState;
    }

    public void EndProcessRequest(IAsyncResult ar)
    {
    }

    void ProcessRequest(object state, DateTime requestTime)
    {
      AsyncRequestState reqState = state as AsyncRequestState;

      // Take some time to do it
      Thread.Sleep(2000);

      reqState._ctx.Response.Output.Write(
                   "AsyncThreadPool, {0}",
                    AppDomain.GetCurrentThreadId);

      // tell asp.net you are finished processing this request
      reqState.CompleteRequest();
    }

  }
}</pre>
<h2>AsyncPage</h2>
<pre>namespace EssentialAspDotNet.HttpPipeline
{
 public class AsyncPage : Page, IHttpAsyncHandler
  {
    static protected DevelopMentor.ThreadPool _threadPool;

    static AsyncPage()
    {
      _threadPool =
       new DevelopMentor.ThreadPool(2, 25, "AsyncPool");
      _threadPool.PropogateCallContext = true;
      _threadPool.PropogateThreadPrincipal = true;
      _threadPool.PropogateHttpContext = true;
      _threadPool.Start();
    }

    public new void ProcessRequest(HttpContext ctx)
    {
      // not used
    }

    public new bool IsReusable
    {
      get { return false;}
    }

    public IAsyncResult BeginProcessRequest(HttpContext ctx,
                                            AsyncCallback cb, object obj)
    {
      AsyncRequestState reqState =
             new AsyncRequestState(ctx, cb, obj);
      _threadPool.PostRequest(
             new DevelopMentor.WorkRequestDelegate(ProcessRequest),
             reqState);

      return reqState;
    }

    public void EndProcessRequest(IAsyncResult ar)
    {
    }

    void ProcessRequest(object state, DateTime requestTime)
    {
      AsyncRequestState reqState = state as AsyncRequestState;

      // Synchronously call base class Page.ProcessRequest
      // as you are now on a thread pool thread.
      base.ProcessRequest(reqState._ctx);

      // Once complete, call CompleteRequest to finish
      reqState.CompleteRequest();
    }
  }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2010/05/async-httphandlers-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Sitemap .NET links</title>
		<link>http://blog.ovesens.net/2010/03/google-sitemap-net-links/</link>
		<comments>http://blog.ovesens.net/2010/03/google-sitemap-net-links/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 19:40:44 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[sitemap]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/?p=226</guid>
		<description><![CDATA[Some links with information about creating a Google Sitemap either directly in XML or via some .NET code. http://gerardmcgarry.com/blog/creating-a-google-sitemap-aspnet-website http://www.codeproject.com/KB/aspnet/GoogleSiteMapProvider.aspx]]></description>
			<content:encoded><![CDATA[<p>Some links with information about creating a Google Sitemap either directly in XML or via some .NET code.</p>
<p><a href="http://gerardmcgarry.com/blog/creating-a-google-sitemap-aspnet-website" target="_blank">http://gerardmcgarry.com/blog/creating-a-google-sitemap-aspnet-website</a></p>
<p><a href="http://www.codeproject.com/KB/aspnet/GoogleSiteMapProvider.aspx" target="_blank">http://www.codeproject.com/KB/aspnet/GoogleSiteMapProvider.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2010/03/google-sitemap-net-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET Resource localization</title>
		<link>http://blog.ovesens.net/2010/02/net-resource-localization/</link>
		<comments>http://blog.ovesens.net/2010/02/net-resource-localization/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 17:17:45 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[resources]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/2010/02/net-resource-localization/</guid>
		<description><![CDATA[ResourceBlender is open source and works for .NET: http://www.resourceblender.com/]]></description>
			<content:encoded><![CDATA[<p>ResourceBlender is open source and works for .NET:</p>
<p><a href="http://www.resourceblender.com/" target="_blank">http://www.resourceblender.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2010/02/net-resource-localization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Must read and references</title>
		<link>http://blog.ovesens.net/2010/01/must-read-and-references/</link>
		<comments>http://blog.ovesens.net/2010/01/must-read-and-references/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 13:56:11 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[nh]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[read]]></category>
		<category><![CDATA[reference]]></category>

		<guid isPermaLink="false">http://blog.ovesens.net/2010/01/must-read-and-references/</guid>
		<description><![CDATA[Read: http://davybrion.com/blog/2009/12/using-nhibernate-in-your-service-layer/ Reference: http://west-wind.com/weblog/posts/132081.aspx]]></description>
			<content:encoded><![CDATA[<p>Read:<br />
<a href="http://davybrion.com/blog/2009/12/using-nhibernate-in-your-service-layer/" target="_blank">http://davybrion.com/blog/2009/12/using-nhibernate-in-your-service-layer/</a></p>
<p>Reference:<br />
<a href="http://west-wind.com/weblog/posts/132081.aspx" target="_blank">http://west-wind.com/weblog/posts/132081.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2010/01/must-read-and-references/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Memoryleaks with WinDbg</title>
		<link>http://blog.ovesens.net/2009/06/memoryleaks-with-windbg/</link>
		<comments>http://blog.ovesens.net/2009/06/memoryleaks-with-windbg/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 12:39:00 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[memoryleaks]]></category>

		<guid isPermaLink="false">/post/2009/06/12/Memoryleaks-with-WinDbg.aspx</guid>
		<description><![CDATA[I have experienced the first major project with a memory leak problem&#8230; and how do one get started with Memory leak finding. It is a tough task andÂ the learning curve is quite steep. You have to get to know the &#8230; <a href="http://blog.ovesens.net/2009/06/memoryleaks-with-windbg/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have experienced the first major project with a memory leak problem&#8230; and how do one get started with Memory leak finding.</p>
<p>It is a tough task andÂ the learning curve is quite steep.</p>
<p>You have to get to know the WinDbg. You can start here: <a href="http://blogs.msdn.com/tess/pages/net-debugging-demos-information-and-setup-instructions.aspx">http://blogs.msdn.com/tess/pages/net-debugging-demos-information-and-setup-instructions.aspx</a></p>
<p>Tess Ferrandez has some very nice &#8220;Debugging labs&#8221;, well take a look at: <a href="http://blogs.msdn.com/tess/">http://blogs.msdn.com/tess/</a></p>
<p>If you have a problem with a memory leak, take a look at his one:</p>
<p><a href="http://blogs.msdn.com/tess/archive/2005/11/25/496899.aspx">http://blogs.msdn.com/tess/archive/2005/11/25/496899.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2009/06/memoryleaks-with-windbg/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Dynamically Loading ASP.NET User Controls with jQuery</title>
		<link>http://blog.ovesens.net/2008/12/dynamically-loading-asp-net-user-controls-with-jquery/</link>
		<comments>http://blog.ovesens.net/2008/12/dynamically-loading-asp-net-user-controls-with-jquery/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 21:17:00 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[usercontrol]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">/post/2008/12/26/Dynamically-Loading-ASPNET-User-Controls-with-jQuery.aspx</guid>
		<description><![CDATA[UPDATE (16-07-2009) Here is a new sample website with source code, it now disposes the page object and allows for WebControl rendering. Dynamically Loading ASP.NET User Controls with jQuery v2.zip (25.52 kb) &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;Â  This post is only relevant if you &#8230; <a href="http://blog.ovesens.net/2008/12/dynamically-loading-asp-net-user-controls-with-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE (16-07-2009)</strong></p>
<p>Here is a new sample website with source code, it now disposes the page object and allows for WebControl rendering.</p>
<p><a href="/wp-content/uploads/archive/Dynamically Loading ASP.NET User Controls with jQuery v2.zip">Dynamically Loading ASP.NET User Controls with jQuery v2.zip (25.52 kb)</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;Â </p>
<p>This post is only relevant if you are using WebForms. If you have converted to the MVC approach, then go read about Dependency Injection or NHibernate <img src='http://blog.ovesens.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If however you are using WebForms or are maintaining an application that was build with WebForms. Here is a way to partially render a usercontrol via jQuery (ajax).</p>
<h2>Introduction</h2>
<p>User controls are a great way to group markup and functionality, but in these AJAX times, the problem and nature of User Controls, in relation to ajax, is their fixed position in the Page Control tree.</p>
<p>Sam Mueller describes the issues and gives his solution to dynamically loaded user controls using jQuery.</p>
<p>Read it here:</p>
<p><a title="http://samuelmueller.com/post/2008/12/20/Dynamically-Loading-ASPNET-User-Controls-with-jQuery.aspx" href="http://samuelmueller.com/post/2008/12/20/Dynamically-Loading-ASPNET-User-Controls-with-jQuery.aspx" target="_blank">http://samuelmueller.com/post/2008/12/20/Dynamically-Loading-ASPNET-User-Controls-with-jQuery.aspx</a></p>
<p>Sam Muellers raises some very interesting points, however I have two things I would like to change (URL and security).</p>
<h2>URL</h2>
<p>I very much like that Sam Mueller has found a solution to &#8220;directly&#8221; call a user control (view) with an URL. What I do not like is the URL to be called:</p>
<div>
<div style="line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">/ajax.svc/renderuc?path=/usercontrols/myusercontrol.ascx</pre>
</div>
</div>
<p>I would like to be able to call the user control directly by this kind of URL:</p>
<div>
<div style="line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">/usercontrols/myusercontrol.ascx</pre>
</div>
</div>
<p>And by using a HttpHandler this is possible. I have written an example here:</p>
<div>
<div style="line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   1:</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> AjaxUserControlHandler : IHttpHandler</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   2:</span>     {</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   3:</span>         <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span> ProcessRequest(HttpContext context)</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   4:</span>         {</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   5:</span>             <span style="color: #008000;">// Get the path to the user control</span></pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   6:</span>             <span style="color: #0000ff;">string</span> path = context.Request.Url.LocalPath;</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   7:</span>Â </pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   8:</span>             <span style="color: #008000;">// Intialize the pseudo page and user control</span></pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   9:</span>             Page page = <span style="color: #0000ff;">new</span> Page();</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  10:</span>             UserControl viewControl = page.LoadControl(path) <span style="color: #0000ff;">as</span> UserControl;</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  11:</span>Â </pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  12:</span>             <span style="color: #008000;">// Display error if the user control was not found</span></pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  13:</span>             <span style="color: #0000ff;">if</span> (viewControl == <span style="color: #0000ff;">null</span>)</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  14:</span>             {</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  15:</span>                 context.Response.StatusCode = 404;</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  16:</span>                 context.Response.Output.WriteLine(<span style="color: #006080;">"The requested url was not found"</span>);</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  17:</span>                 <span style="color: #0000ff;">return</span>;</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  18:</span>             }</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  19:</span>Â </pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  20:</span>             <span style="color: #008000;">// Check existense of the AjaxEnabled attribute. Only add the AjaxEnabled attribut to </span></pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  21:</span>             <span style="color: #008000;">// user controls that is safe for direct calls</span></pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  22:</span>             var type = viewControl.GetType();</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  23:</span>             var attributes = type.GetCustomAttributes(<span style="color: #0000ff;">typeof</span> (AjaxEnabledAttribute), <span style="color: #0000ff;">true</span>);</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  24:</span>             AjaxEnabledAttribute attribute = attributes.FirstOrDefault() <span style="color: #0000ff;">as</span> AjaxEnabledAttribute;</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  25:</span>Â </pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  26:</span>             <span style="color: #008000;">// If the attribute was not found, display an error</span></pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  27:</span>             <span style="color: #0000ff;">if</span> (attribute == <span style="color: #0000ff;">null</span>)</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  28:</span>             {</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  29:</span>                 context.Response.StatusCode = 403;</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  30:</span>                 context.Response.Output.WriteLine(<span style="color: #006080;">"Access to the resource is not allowed"</span>);</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  31:</span>                 <span style="color: #0000ff;">return</span>;</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  32:</span>             }</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  33:</span>Â </pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  34:</span></pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  35:</span>             <span style="color: #008000;">// Check if the request is valiud with regards to the requirements of the attribute.</span></pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  36:</span>             <span style="color: #008000;">// If not, display error</span></pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  37:</span>             <span style="color: #0000ff;">if</span> ((attribute.Method == RequestMethodSupport.GET &amp;&amp; context.Request.RequestType != <span style="color: #006080;">"GET"</span>)</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  38:</span>                 || (attribute.Method == RequestMethodSupport.POST &amp;&amp; context.Request.RequestType != <span style="color: #006080;">"POST"</span>))</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  39:</span>             {</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  40:</span>                 context.Response.StatusCode = 403;</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  41:</span>                 context.Response.Output.WriteLine(<span style="color: #0000ff;">string</span>.Format(<span style="color: #006080;">"The request method {0} is not allowed."</span>, context.Request.RequestType));</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  42:</span>                 <span style="color: #0000ff;">return</span>;</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  43:</span>             }</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  44:</span>Â </pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  45:</span>             <span style="color: #008000;">// Add user control to the pages control tree</span></pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  46:</span>             page.Controls.Add(viewControl);</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  47:</span>Â </pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  48:</span>             <span style="color: #008000;">// Disable caching, remove this if you will allow client caching</span></pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  49:</span>             context.Response.CacheControl = <span style="color: #006080;">"No-Cache"</span>;</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  50:</span>Â </pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  51:</span>             <span style="color: #008000;">// Execute and return result to Output stream</span></pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  52:</span>             context.Server.Execute(page, context.Response.Output, <span style="color: #0000ff;">true</span>);</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  53:</span>         }</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  54:</span>Â </pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  55:</span>         <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">bool</span> IsReusable</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  56:</span>         {</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  57:</span>             get { <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">true</span>; }</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  58:</span>         }</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  59:</span>     }</pre>
</div>
</div>
<p>To make it work, you need to add the following to httpHandlers tag in the web.config.</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">verb</span><span class="kwrd">="*"</span> <span class="attr">path</span><span class="kwrd">="*.ascx"</span> <span class="attr">type</span><span class="kwrd">="[NAMESPACE].AjaxUserControlHandler, [ASSEMBLY]"</span><span class="kwrd">/&gt;</span></pre>
<h2>Security</h2>
<p>I have implemented an AjaxEnabled attribut, so that it is not possible to directly call any of the user controls (if you know the path to them) in the solution.</p>
<p>The attribute is simple and looks like this:</p>
<div>
<div style="line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   1:</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> AjaxEnabledAttribute : Attribute</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   2:</span> {</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   3:</span>     [DefaultValue(RequestMethodSupport.All)]</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   4:</span>     <span style="color: #0000ff;">public</span> RequestMethodSupport Method { get; set; }</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   5:</span> }</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   6:</span>Â </pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   7:</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">enum</span> RequestMethodSupport</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   8:</span> {</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   9:</span>     All,</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  10:</span>     GET,</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  11:</span>     POST</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">  12:</span> }</pre>
</div>
</div>
<p>By doing this, the handler will only allow calls to user controls that have the [AjaxEnabled[ attribute, like this:</p>
<div>
<div style="line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   1:</span> [AjaxEnabled]</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   2:</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">partial</span> <span style="color: #0000ff;">class</span> Test : System.Web.UI.UserControl</pre>
<pre style="line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   3:</span> {</pre>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #606060;">   4:</span>     ...</pre>
</div>
</div>
<h2>Conclusion</h2>
<p>With the HttpHandler, and the attribute in place, my two concerns (url and security) are dealt with.</p>
<p>You are now able to call a user control directly:</p>
<p>/usercontrols/myusercontrol.ascx</p>
<p>And you are only able to call user controls that have the AjaxEnabled attribute.</p>
<p>Any comments and suggestions are welcome btw <img src='http://blog.ovesens.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2008/12/dynamically-loading-asp-net-user-controls-with-jquery/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Create Word Documents using .NET without Interop</title>
		<link>http://blog.ovesens.net/2008/12/create-word-documents-using-net-without-interop/</link>
		<comments>http://blog.ovesens.net/2008/12/create-word-documents-using-net-without-interop/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 12:43:00 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[office]]></category>
		<category><![CDATA[word]]></category>

		<guid isPermaLink="false">/post/2008/12/24/Create-Word-Documents-using-NET-without-Interop.aspx</guid>
		<description><![CDATA[Original blog post: http://www.invoke.co.nz/products/docx.aspx &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; We have decided to release another component we&#39;ve been using (FREE of charge, click here to download). This library creates Word Documents (.docx) using .NET. It is written purely in C#, you don&#39;t need any &#8230; <a href="http://blog.ovesens.net/2008/12/create-word-documents-using-net-without-interop/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
Original blog post:
</p>
<p>
<a href="http://www.invoke.co.nz/products/docx.aspx">http://www.invoke.co.nz/products/docx.aspx</a>
</p>
<p>
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
</p>
<p>
We have decided to release another component we&#39;ve been using (FREE of charge, <a href="http://www.invoke.co.nz/products/docx.aspx" target="_blank" title="Dowload Create Word Document using .NET Library">click here to download</a>).<br />
This library creates Word Documents (.docx) using .NET. It is written<br />
purely in C#, you don&#39;t need any Word viewing applications or Interop<br />
(COM) dlls installed/registered.</p>
<p>It works very similar to a<br />
Repeater control, instead of HTML markup you create a docx template<br />
using Word 2007 (Open XML format), specify parameters/placeholders to<br />
hold values then pass the document to the library, it will then merge<br />
those fields.
</p>
<p>
Here&#39;s an example:<br />
<strong>To create a Word (.docx document)</strong><br />
- Open up Word 2007, create a new file and type in the following (without the &quot; &quot;):<br />
&quot;<strong>Hello %NAME%</strong>&quot;<br />
- Save &amp; Exit (save as hello.docx)</p>
<p>- Create a new VS 2008 Console Application project, add a reference to the docx library, copy paste the code into Program.cs
</p>
<div style="background: white none repeat scroll 0% 0%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<pre style="margin: 0px">
<span style="color: blue">static</span> <span style="color: blue">void</span> Main(<span style="color: blue">string</span>[] args)
</pre>
<pre style="margin: 0px">
{
</pre>
<pre style="margin: 0px">
&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">File</span>.Copy(<span style="color: #a31515">&quot;hello.docx&quot;</span>, <span style="color: #a31515">&quot;hello_ready.docx&quot;</span>, <span style="color: blue">true</span>); <span style="color: green">// create a copy of template file for later use
</span><span style="color: green">    // DocumentDataSource holds name/value pair data</span>
</pre>
<pre style="margin: 0px">
&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">DocumentDataSource</span> source = <span style="color: blue">new</span> <span style="color: #2b91af">DocumentDataSource</span>();
</pre>
<pre style="margin: 0px">
&nbsp;
</pre>
<pre style="margin: 0px">
&nbsp;&nbsp;&nbsp; source[<span style="color: #a31515">&quot;NAME&quot;</span>] = <span style="color: #a31515">&quot;Joe Bloggs&quot;</span>; <span style="color: green">// assign a value to parameter %NAME%</span>
</pre>
<pre style="margin: 0px">
&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">DocumentRenderer</span>.ProcessDocument(<span style="color: #a31515">&quot;hello_ready.docx&quot;</span>, source); <span style="color: green">// process the document</span>
</pre>
<pre style="margin: 0px">
&nbsp;
</pre>
<pre style="margin: 0px">
&nbsp;&nbsp;&nbsp; <span style="color: #2b91af">Process</span>.Start(<span style="color: #a31515">&quot;hello_ready.docx&quot;</span>); <span style="color: green">// run MS Word to see merged document</span>
</pre>
<pre style="margin: 0px">
}
</pre>
</div>
<p>
<strong>Result</strong><br />
<img src="http://www.invoke.co.nz/products/help/docx/result_hello.jpg" alt="Create a Word Document using C# without Interop (COM)" title="Create a Word Document using C# without Interop (COM)" hspace="5" vspace="5" width="600" height="278" align="middle" /></p>
<p>That&#39;s an over simplified example, the library is able to do a lot more, if you&#39;d like to download it or find out more please <a href="http://www.invoke.co.nz/products/docx.aspx" target="_blank" title="Create a Word Document (Open XML format) using .NET without Interop">click here</a>, </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2008/12/create-word-documents-using-net-without-interop/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Prevent Cross-Site Request Forgery (CSRF) using ASP.NET MVC AntiForgeryToken helper</title>
		<link>http://blog.ovesens.net/2008/11/prevent-cross-site-request-forgery-csrf-using-asp-net-mvc-antiforgerytoken-helper/</link>
		<comments>http://blog.ovesens.net/2008/11/prevent-cross-site-request-forgery-csrf-using-asp-net-mvc-antiforgerytoken-helper/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 16:25:00 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">/post/2008/11/26/Prevent-Cross-Site-Request-Forgery-(CSRF)-using-ASPNET-MVC-AntiForgeryToken-helper.aspx</guid>
		<description><![CDATA[Original post: http://blog.codeville.net/2008/09/01/prevent-cross-site-request-forgery-csrf-using-aspnet-mvcs-antiforgerytoken-helper/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; Cross-site scripting (XSS) is widely regarded as the number one security issue on the web. But since XSS gets all the limelight, few developers pay much attention to another form of attack that&#8217;s equally destructive and &#8230; <a href="http://blog.ovesens.net/2008/11/prevent-cross-site-request-forgery-csrf-using-asp-net-mvc-antiforgerytoken-helper/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
Original post:
</p>
<p>
<a href="http://blog.codeville.net/2008/09/01/prevent-cross-site-request-forgery-csrf-using-aspnet-mvcs-antiforgerytoken-helper/" title="http://blog.codeville.net/2008/09/01/prevent-cross-site-request-forgery-csrf-using-aspnet-mvcs-antiforgerytoken-helper/">http://blog.codeville.net/2008/09/01/prevent-cross-site-request-forgery-csrf-using-aspnet-mvcs-antiforgerytoken-helper/</a>
</p>
<p>
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
</p>
<p>
Cross-site scripting (XSS) is <a href="http://www.owasp.org/index.php/Top_10_2007">widely</a> <a href="http://tinyurl.com/3q9j7w">regarded</a> as the number one security issue on the web. But since XSS gets all the limelight, few developers pay much attention to another form of attack that&rsquo;s equally destructive and potentially far easier to exploit. Your application can be vulnerable to cross-site request forgery (CSRF) attacks not because you the developer did something wrong (as in, failing to encode outputs leads to XSS), but simply because of how the whole Web is designed to work. Scary!
</p>
<h6>How CSRF works</h6>
<p>
So, what&rsquo;s it all about? All web application platforms are potentially vulnerable to CSRF, but in this post I&rsquo;ll focus on ASP.NET MVC. Imagine you have a controller class as follows:
</p>
<div class="csharpcode">
<pre class="alt">
<span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">class</span> UserProfileController : Controller
</pre>
<pre>
<span class="lnum">   2:  </span>{
</pre>
<pre class="alt">
<span class="lnum">   3:  </span>    <span class="kwrd">public</span> ViewResult Edit() { <span class="kwrd">return</span> View(); }
</pre>
<pre>
<span class="lnum">   4:  </span>
</pre>
<pre class="alt">
<span class="lnum">   5:  </span>    <span class="kwrd">public</span> ViewResult SubmitUpdate()
</pre>
<pre>
<span class="lnum">   6:  </span>    {
</pre>
<pre class="alt">
<span class="lnum">   7:  </span>        <span class="rem">// Get the user&#39;s existing profile data (implementation omitted)</span>
</pre>
<pre>
<span class="lnum">   8:  </span>        ProfileData profile = GetLoggedInUserProfile();
</pre>
<pre class="alt">
<span class="lnum">   9:  </span>
</pre>
<pre>
<span class="lnum">  10:  </span>        <span class="rem">// Update the user object</span>
</pre>
<pre class="alt">
<span class="lnum">  11:  </span>        profile.EmailAddress = Request.Form[<span class="str">&quot;email&quot;</span>];
</pre>
<pre>
<span class="lnum">  12:  </span>        profile.FavoriteHobby = Request.Form[<span class="str">&quot;hobby&quot;</span>];
</pre>
<pre class="alt">
<span class="lnum">  13:  </span>        SaveUserProfile(profile);
</pre>
<pre>
<span class="lnum">  14:  </span>
</pre>
<pre class="alt">
<span class="lnum">  15:  </span>        TempData[<span class="str">&quot;message&quot;</span>] = <span class="str">&quot;Your profile was updated.&quot;</span>;
</pre>
<pre>
<span class="lnum">  16:  </span>        <span class="kwrd">return</span> View();
</pre>
<pre class="alt">
<span class="lnum">  17:  </span>    }
</pre>
<pre>
<span class="lnum">  18:  </span>}
</pre>
</div>
<p>
This is all very normal. First, the visitor goes to <strong>Edit()</strong>, which renders some form to let them change their user profile details. Secondly, they post that form to <strong>SubmitUpdate()</strong>, which saves the changes to their profile record in the database. There&rsquo;s no XSS vulnerability here. Everything&rsquo;s fine, right? We implement this sort of thing all the time&hellip;
</p>
<p>
Unfortunately, this innocent controller is an easy target for CSRF. Imagine that an attacker sets up the following HTML page and hosts it on some server of their own:
</p>
<div class="csharpcode">
<pre class="alt">
<span class="lnum">   1:  </span><span class="kwrd">&lt;</span><span class="html">body</span> <span class="attr">onload</span><span class="kwrd">=&quot;document.getElementById(&#39;fm1&#39;).submit()&quot;</span><span class="kwrd">&gt;</span>
</pre>
<pre>
<span class="lnum">   2:  </span>    <span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">id</span><span class="kwrd">=&quot;fm1&quot;</span> <span class="attr">action</span><span class="kwrd">=&quot;http://yoursite/UserProfile/SubmitUpdate&quot;</span> <span class="attr">method</span><span class="kwrd">=&quot;post&quot;</span><span class="kwrd">&gt;</span>
</pre>
<pre class="alt">
<span class="lnum">   3:  </span>        <span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">name</span><span class="kwrd">=&quot;email&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;hacker@somewhere.evil&quot;</span> <span class="kwrd">/&gt;</span>
</pre>
<pre>
<span class="lnum">   4:  </span>        <span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">name</span><span class="kwrd">=&quot;hobby&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;Defacing websites&quot;</span> <span class="kwrd">/&gt;</span>
</pre>
<pre class="alt">
<span class="lnum">   5:  </span>    <span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span>
</pre>
<pre>
<span class="lnum">   6:  </span><span class="kwrd">&lt;/</span><span class="html">body</span><span class="kwrd">&gt;</span>
</pre>
</div>
<p>
Next, they somehow persuade a victim to visit this page (basic social engineering, look it up). When this HTML page loads, it submits a valid form post to <strong>/UserProfile/SubmitUpdate</strong> on <em>your server</em>.
</p>
<p>
Assuming you&rsquo;re using Windows authentication or some kind of cookie-based authentication system such as Forms Authentication, the automated form post will be processed within the victim&rsquo;s established authentication context, and will successfully update the victim&rsquo;s email address to something under the attacker&rsquo;s control. All the attacker has to do now is use your &ldquo;forgotten password&rdquo; facility, and they&rsquo;re taken control of the victim&rsquo;s account.
</p>
<p>
Of course, instead of changing an victim&rsquo;s email address, they can perform any action that the victim can perform with a single POST request. For example, they might be able to grant administrative permissions to another account, or post something defamatory to a CMS.
</p>
<h6>Ways to stop CSRF</h6>
<p>
There are two main ways to block CSRF:
</p>
<ul>
<li>Check that incoming requests have a <strong>Referer</strong> header referencing your domain. This will stop requests unwittingly submitted from a third-party domain. However, some people disable their browser&rsquo;s <strong>Referer</strong> header for privacy reasons, and attackers can sometimes spoof that header if the victim has certain versions of Adobe Flash installed. This is a weak solution. </li>
<li>Put a user-specific token as a hidden field in legitimate forms, and check that the right value was submitted. If, for example, this token is the user&rsquo;s password, then a third-party can&rsquo;t forge a valid form post, because they don&rsquo;t know each user&rsquo;s password. However, don&rsquo;t expose the user&rsquo;s password this way: Instead, it&rsquo;s better to use some random value (such as a GUID) which you&rsquo;ve stored in the visitor&rsquo;s Session collection or into a Cookie. </li>
</ul>
<h6>Using the AntiForgeryToken helpers</h6>
<p>
With Preview 5, Microsoft has added a set of helpers to the &ldquo;futures&rdquo; assembly, Microsoft.Web.Mvc.dll, that give you a means to detect and block CSRF using the &ldquo;user-specific tokens&rdquo; technique.
</p>
<p>
To use these helpers to protect a particular form, put an Html.AntiForgeryToken() into the form, e.g.,
</p>
<div class="csharpcode">
<pre class="alt">
<span class="lnum">   1:  </span><span class="asp">&lt;%</span> <span class="kwrd">using</span>(Html.Form(<span class="str">&quot;UserProfile&quot;</span>, <span class="str">&quot;SubmitUpdate&quot;</span>)) { <span class="asp">%&gt;</span>
</pre>
<pre>
<span class="lnum">   2:  </span>    <span class="asp">&lt;%</span>= Html.AntiForgeryToken() <span class="asp">%&gt;</span>
</pre>
<pre class="alt">
<span class="lnum">   3:  </span>    <span class="rem">&lt;!-- rest of form goes here --&gt;</span>
</pre>
<pre>
<span class="lnum">   4:  </span><span class="asp">&lt;%</span> } <span class="asp">%&gt;</span>
</pre>
</div>
<p>
This will output something like the following:
</p>
<div class="csharpcode">
<pre class="alt">
<span class="lnum">   1:  </span><span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">action</span><span class="kwrd">=&quot;/UserProfile/SubmitUpdate&quot;</span> <span class="attr">method</span><span class="kwrd">=&quot;post&quot;</span><span class="kwrd">&gt;</span>
</pre>
<pre>
<span class="lnum">   2:  </span>    <span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">name</span><span class="kwrd">=&quot;__MVC_AntiForgeryToken&quot;</span> <span class="attr">type</span><span class="kwrd">=&quot;hidden&quot;</span> <span class="attr">value</span><span class="kwrd">=&quot;saTFWpkKN0BYazFtN6c4YbZAmsEwG0srqlUqqloi/fVgeV2ciIFVmelvzwRZpArs&quot;</span> <span class="kwrd">/&gt;</span>
</pre>
<pre class="alt">
<span class="lnum">   3:  </span>    <span class="rem">&lt;!-- rest of form goes here --&gt;</span>
</pre>
<pre>
<span class="lnum">   4:  </span><span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span>
</pre>
</div>
<p>
At the same time, Html.AntiForgeryToken() will give the visitor a cookie called __MVC_AntiForgeryToken, with the same value as the random hidden value shown above.
</p>
<p>
Next, to validate an incoming form post, add the [ValidateAntiForgeryToken] filter to your target action method. For example,
</p>
<div class="csharpcode">
<pre class="alt">
<span class="lnum">   1:  </span>[ValidateAntiForgeryToken]
</pre>
<pre>
<span class="lnum">   2:  </span><span class="kwrd">public</span> ViewResult SubmitUpdate()
</pre>
<pre class="alt">
<span class="lnum">   3:  </span>{
</pre>
<pre>
<span class="lnum">   4:  </span>    <span class="rem">// ... etc</span>
</pre>
<pre class="alt">
<span class="lnum">   5:  </span>}
</pre>
</div>
<p>
This is an authorization filter that checks that:
</p>
<ul>
<li>The incoming request has a cookie called <strong>__MVC_AntiForgeryToken</strong></li>
<li>The incoming request has a Request.Form entry called <strong>__MVC_AntiForgeryToken</strong></li>
<li>These cookie and Request.Form values match </li>
</ul>
<p>
Assuming all is well, the request goes through as normal. But if not, boom!, there&rsquo;s an authorization failure with message &ldquo;A required anti-forgery token was not supplied or was invalid&rdquo;.
</p>
<p>
This prevents CSRF because even if a potential victim has an <strong>__MVC_AntiForgeryToken</strong> cookie, an attacker can&rsquo;t find out its value, so they can&rsquo;t forge a valid form post with the same value in Request.Form. But legitimate users aren&rsquo;t inconvenienced at all; the mechanism is totally silent.
</p>
<h6>Using salt</h6>
<p>
Salt? What? In case you want to protect multiple forms in your application independently of each other, you can use a &ldquo;salt&rdquo; value when you call Html.AntiForgeryToken(), e.g.,
</p>
<div class="csharpcode">
<pre class="alt">
<span class="lnum">   1:  </span><span class="asp">&lt;%</span>= Html.AntiForgeryToken(<span class="str">&quot;someArbitraryString&quot;</span>) <span class="asp">%&gt;</span>
</pre>
</div>
<p>
&hellip; and also in [ValidateAntiForgeryToken], e.g.,
</p>
<div class="csharpcode">
<pre class="alt">
<span class="lnum">   1:  </span>[ValidateAntiForgeryToken(Salt=<span class="str">&quot;someArbitraryString&quot;</span>)]
</pre>
<pre>
<span class="lnum">   2:  </span><span class="kwrd">public</span> ViewResult SubmitUpdate()
</pre>
<pre class="alt">
<span class="lnum">   3:  </span>{
</pre>
<pre>
<span class="lnum">   4:  </span>    <span class="rem">// ... etc</span>
</pre>
<pre class="alt">
<span class="lnum">   5:  </span>}
</pre>
</div>
<p>
&nbsp;
</p>
<p>
Salt is just an arbitrary string. A different salt value means a different anti-forgery token will be generated. This means that even if an attacker manages to get hold of a valid token somehow, they can&rsquo;t reuse it in other parts of the application where a different salt value is required. (If anyone can suggest other use cases for salt, please let me know.)
</p>
<h6>Limitations of the Anti-Forgery helpers</h6>
<p>
ASP.NET MVC&rsquo;s anti-CSRF helpers work very nicely, but you should be aware of a few limitations:
</p>
<ul>
<li>All legitimate visitors must accept cookies (otherwise, [ValidateAntiForgeryToken] will deny their form posts). Arguably this isn&rsquo;t a limitation, because unless visitors allow cookies, you probably don&rsquo;t have anything to protect anyway. </li>
<li>It only works with POST requests, not GET requests. Arguably this isn&rsquo;t a limitation, because under the normal HTTP conventions, you shouldn&rsquo;t be using GET requests for anything other than read-only operations. </li>
<li>It&rsquo;s easily bypassed if you have any XSS holes on your domain. An XSS hole would allow an attacker to read a victim&rsquo;s anti-forgery token value, then use it to forge valid posts. So, don&rsquo;t have XSS holes! </li>
<li>It relies on the potential victim&rsquo;s browser implementing cross-domain boundaries solidly. Browsers are supposed to stop foreign domains from reading your app&rsquo;s response text and cookies, and are supposed to stop foreign domains from writing cookies to your domain. If an attacker manages to find a way around this, they can bypass [ValidateAntiForgeryToken]. Of course that&rsquo;s not supposed to be possible. For the most part, modern browsers block this line of attack. </li>
</ul>
<p>
In conclusion, ASP.NET MVC&rsquo;s anti-CSRF helpers are easy to use, and work very nicely thank you!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2008/11/prevent-cross-site-request-forgery-csrf-using-asp-net-mvc-antiforgerytoken-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New ASP.NET Charting Control</title>
		<link>http://blog.ovesens.net/2008/11/new-asp-net-charting-control/</link>
		<comments>http://blog.ovesens.net/2008/11/new-asp-net-charting-control/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 10:48:00 +0000</pubDate>
		<dc:creator>Mikkel Ovesen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[webforms]]></category>

		<guid isPermaLink="false">/post/2008/11/26/New-ASPNET-Charting-Control.aspx</guid>
		<description><![CDATA[Microsoft released a free ASP.NET charting controls. Read more about it here: http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx Or take a qucik look directly on these following link: Microsoft recently released a cool new ASP.NET server control &#8211; &#60;asp:chart /&#62; &#8211; that can be used &#8230; <a href="http://blog.ovesens.net/2008/11/new-asp-net-charting-control/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
Microsoft released a free ASP.NET charting controls.
</p>
<p>
Read more about it here:
</p>
<p>
<a href="http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx">http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx</a>
</p>
<p>
Or take a qucik look directly on these following link:
</p>
<p>
Microsoft recently released a cool new ASP.NET server control &#8211; &lt;asp:chart /&gt; &#8211; that can be used for free with ASP.NET 3.5 to enable rich browser-based charting scenarios:
</p>
<ul>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&amp;DisplayLang=en" target="_blank">Download the free Microsoft Chart Controls</a> </li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?familyid=1D69CE13-E1E5-4315-825C-F14D33A303E9&amp;displaylang=en" target="_blank">Download the VS 2008 Tool Support for the Chart Controls</a> </li>
<li><a href="http://code.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=1591" target="_blank">Download the Microsoft Chart Controls Samples</a> </li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=EE8F6F35-B087-4324-9DBA-6DD5E844FD9F&amp;displaylang=en" target="_blank">Download the Microsoft Chart Controls Documentation</a> </li>
<li><a href="http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/threads/" target="_blank">Visit the Microsoft Chart Control Forum</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.ovesens.net/2008/11/new-asp-net-charting-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

