<?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>Prolific Notion &#187; ASP.NET</title>
	<atom:link href="http://www.prolificnotion.co.uk/tag/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.prolificnotion.co.uk</link>
	<description>Welcome to the miscellaneous mutterings of Simon Dingley, Freelance Web Developer</description>
	<lastBuildDate>Sat, 24 Jul 2010 14:23:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Convert HTML to Plain Text in C# using Markdown</title>
		<link>http://www.prolificnotion.co.uk/convert-html-to-plain-text-in-c-using-markdown/</link>
		<comments>http://www.prolificnotion.co.uk/convert-html-to-plain-text-in-c-using-markdown/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 13:41:12 +0000</pubDate>
		<dc:creator>Simon Dingley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.prolificnotion.co.uk/?p=262</guid>
		<description><![CDATA[Creating a plain-text version of HTML that is suitable to be sent out as the text part of a multi-part email. Using C# and XSLT I have developed a working solution to the problem with help from a third party markdown XSLT file.


Related posts:<ol><li><a href='http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-world-currencies/' rel='bookmark' title='Permanent Link: C# Utility method to populate list controls with world currencies'>C# Utility method to populate list controls with world currencies</a> <small>A requirement that came up recently required a drop down...</small></li>
<li><a href='http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-all-countries-as-given-in-iso-3166-1/' rel='bookmark' title='Permanent Link: C# Utility method to populate list controls with all countries as given in ISO 3166-1'>C# Utility method to populate list controls with all countries as given in ISO 3166-1</a> <small>Most projects I work on need a list of countries...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fconvert-html-to-plain-text-in-c-using-markdown%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fconvert-html-to-plain-text-in-c-using-markdown%2F&amp;style=normal&amp;service=bit.ly&amp;service_api=R_e35365ff035ed93fc3e67e6f868b7be3" height="61" width="50" /><br />
			</a>
		</div>
<p>While working on my customisations to <a style="outline-style: none; outline-width: initial; outline-color: initial; color: #33707e; text-decoration: underline; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://www.nibble.be/">Tim Geyssens</a> <a style="outline-style: none; outline-width: initial; outline-color: initial; color: #33707e; text-decoration: underline; padding: 0px; margin: 0px; border: 0px initial initial;" href="http://www.nibble.be/?p=63">MailEngine</a> I was looking for an accurate method of automatically creating a plain-text version of the HTML emails that were being sent out by the site. Further reading brought my attention to something called <a title="Read more about Markdown here" href="http://en.wikipedia.org/wiki/Markdown">Markdown</a>. After some hunting around with a little help from my friend Google I managed to find a markdown XSLT file. Using the XSLT I could transform my HTML email to plain-text with relative ease and accuracy. Of course in order to do this I would need a valid XML document and as my pages were already valid XHTML I had no problems there.</p>
<p>Here is my method for doing the conversion, all it requires is that you pass it the HTML you want to convert which must be valid XML:</p>
<pre class="brush: csharp;">/// &lt;summary&gt;
/// Converts to HTML to plain-text.
/// &lt;/summary&gt;
/// &lt;param name=&quot;HTML&quot;&gt;The HTML.&lt;/param&gt;
/// &lt;returns&gt;The plain text representation of the HTML&lt;/returns&gt;
private static string ConvertToText(string HTML)
{
    string text = string.Empty;

    XmlDocument xmlDoc = new XmlDocument();
    XmlDocument xsl = new XmlDocument();
    xmlDoc.LoadXml(HTML);
    xsl.CreateEntityReference(&quot;nbsp&quot;);
    xsl.Load(System.Web.HttpContext.Current.Server.MapPath(&quot;/xslt/Markdown.xslt&quot;));

    //creating xslt
    XslTransform xslt = new XslTransform();
    xslt.Load(xsl, null, null);

    //creating stringwriter
    StringWriter writer = new System.IO.StringWriter();

    //Transform the xml.
    xslt.Transform(xmlDoc, null, writer, null);

    //return string
    text = writer.ToString();
    writer.Close();

    return text;
}</pre>
<p>Download the XSLT file I used from here:</p>
<p><a href="http://symphony-cms.com/downloads/xslt/file/20573/">http://symphony-cms.com/downloads/xslt/file/20573/</a></p>
<p>I would love to hear from anyone that does this differently or if you can find any problems with the method I have chosen to implement for this solution.</p>


<p>Related posts:<ol><li><a href='http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-world-currencies/' rel='bookmark' title='Permanent Link: C# Utility method to populate list controls with world currencies'>C# Utility method to populate list controls with world currencies</a> <small>A requirement that came up recently required a drop down...</small></li>
<li><a href='http://www.prolificnotion.co.uk/c-utility-method-to-populate-list-controls-with-all-countries-as-given-in-iso-3166-1/' rel='bookmark' title='Permanent Link: C# Utility method to populate list controls with all countries as given in ISO 3166-1'>C# Utility method to populate list controls with all countries as given in ISO 3166-1</a> <small>Most projects I work on need a list of countries...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.prolificnotion.co.uk/convert-html-to-plain-text-in-c-using-markdown/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>SmtpClient does not gracefully close the underlying TCP/IP connection</title>
		<link>http://www.prolificnotion.co.uk/smtpclient-does-not-gracefully-close-the-underlying-tcpip-connection/</link>
		<comments>http://www.prolificnotion.co.uk/smtpclient-does-not-gracefully-close-the-underlying-tcpip-connection/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 10:43:17 +0000</pubDate>
		<dc:creator>Simon Dingley</dc:creator>
				<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.prolificnotion.co.uk/?p=246</guid>
		<description><![CDATA[Some months back Tim Geyssens was kind enough to send me the source for his MailEngine addition to Umbraco before he released it on his blog. I made some customisations to the source to allow users to select templates and changed the filtering options slightly but other than that it worked jut fine for what [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fsmtpclient-does-not-gracefully-close-the-underlying-tcpip-connection%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fsmtpclient-does-not-gracefully-close-the-underlying-tcpip-connection%2F&amp;style=normal&amp;service=bit.ly&amp;service_api=R_e35365ff035ed93fc3e67e6f868b7be3" height="61" width="50" /><br />
			</a>
		</div>
<p>Some months back <a href="http://www.nibble.be/">Tim Geyssens</a> was kind enough to send me the source for his <a href="http://www.nibble.be/?p=63">MailEngine</a> addition to Umbraco before he released it on his blog. I made some customisations to the source to allow users to select templates and changed the filtering options slightly but other than that it worked jut fine for what I needed.</p>
<p>There was however one problem that became apparent when this was used in production. Sometimes, and apparently randomly the sending of mail would freeze when going to more than say 150 recipients. After a long time trying to track down the reason I stumbled across a post linking to the &#8216;<a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=146711&amp;wa=wsignin1.0">SmtpClient does not gracefully close the underlying TCP/IP connection</a>&#8216; issue on the Microsoft Connect website. I guessed it couldn&#8217;t do any harm to set the MaxTimeout property of the SmtpClient to 1 so I tried it and it seemed to work &#8211; so far so good however you should note the recent comment from someone with regards to using this method on IIS7.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.prolificnotion.co.uk/smtpclient-does-not-gracefully-close-the-underlying-tcpip-connection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8216;Sys&#8217; is Undefined in ASP.NET AJAX</title>
		<link>http://www.prolificnotion.co.uk/sys-is-undefined-in-aspnet-ajax/</link>
		<comments>http://www.prolificnotion.co.uk/sys-is-undefined-in-aspnet-ajax/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 11:11:25 +0000</pubDate>
		<dc:creator>Simon Dingley</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://blog.prolificnotion.co.uk/?p=29</guid>
		<description><![CDATA[A project that I was updating recently didn&#8217;t start out its life as an ASP.NET AJAX enabled application so it was being upgraded to take advantage of some of the features and controls available in the AjaxControlToolkit. I added the necessary references to my project and added the assemblies to the Web.config and things seemed [...]


Related posts:<ol><li><a href='http://www.prolificnotion.co.uk/running-umbraco-v4-on-aspnet-35/' rel='bookmark' title='Permanent Link: Running Umbraco v4 on ASP.NET 3.5'>Running Umbraco v4 on ASP.NET 3.5</a> <small>A project I am currently working on is based on...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fsys-is-undefined-in-aspnet-ajax%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.prolificnotion.co.uk%2Fsys-is-undefined-in-aspnet-ajax%2F&amp;style=normal&amp;service=bit.ly&amp;service_api=R_e35365ff035ed93fc3e67e6f868b7be3" height="61" width="50" /><br />
			</a>
		</div>
<p>A project that I was updating recently didn&#8217;t start out its life as an <a title="Discover more about ASP.NET AJAX" href="http://www.asp.net/ajax/">ASP.NET AJAX</a> enabled application so it was being upgraded to take advantage of some of the features and controls available in the <a title="Find out more about the AJAX Control Toolkit" href="http://www.asp.net/ajax/ajaxcontroltoolkit/">AjaxControlToolkit</a>. I added the necessary references to my project and added the assemblies to the Web.config and things seemed ok until I got to a page with an <a title="UpdatePanel Control Overview" href="http://www.asp.net/Ajax/Documentation/Live/overview/UpdatePanelOverview.aspx">UpdatePanel</a> on it and the dreaded <strong>&#8216;Sys&#8217; is undefined</strong> error reared its ugly head. After a lot of head scratching and some failed Google-fu I finally manaeged to find a <a href="http://geekswithblogs.net/ranganh/archive/2007/07/15/113963.aspx">post</a> which led me to my answer. I was missing the httpHandlers and httpModules configuration settings in my Web.config which if I had created a new ASP.NET AJAX enabled project from scratch would already have existed, adding them in and the error went away and now my <a title="UpdatePanel Control Overview" href="http://www.asp.net/Ajax/Documentation/Live/overview/UpdatePanelOverview.aspx">UpdatePanel</a> started to work as required.</p>
<p>
<pre class="brush: xml;">&lt;httpHandlers&gt;&lt;br /&gt;
  &lt;remove verb=&quot;*&quot; path=&quot;*.asmx&quot;/&gt;&lt;br /&gt;
  &lt;add verb=&quot;*&quot; path=&quot;*.asmx&quot; validate=&quot;false&quot; type=&quot;System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;/&gt;&lt;br /&gt;
  &lt;add verb=&quot;*&quot; path=&quot;*_AppService.axd&quot; validate=&quot;false&quot; type=&quot;System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;/&gt;&lt;br /&gt;
  &lt;add verb=&quot;GET,HEAD&quot; path=&quot;ScriptResource.axd&quot; type=&quot;System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; validate=&quot;false&quot;/&gt;&lt;br /&gt;
&lt;/httpHandlers&gt;&lt;/p&gt;
&lt;p&gt;&lt;httpModules&gt;&lt;br /&gt;
  &lt;add name=&quot;ScriptModule&quot; type=&quot;System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;/&gt;&lt;br /&gt;
&lt;/httpModules&gt; </pre></p>


<p>Related posts:<ol><li><a href='http://www.prolificnotion.co.uk/running-umbraco-v4-on-aspnet-35/' rel='bookmark' title='Permanent Link: Running Umbraco v4 on ASP.NET 3.5'>Running Umbraco v4 on ASP.NET 3.5</a> <small>A project I am currently working on is based on...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.prolificnotion.co.uk/sys-is-undefined-in-aspnet-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
