<?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>Stronico - Steroids for Networking &#187; ASP.net MVC</title>
	<atom:link href="http://blog.stronico.com/category/asp-net-mvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stronico.com</link>
	<description>We help the world’s best salesmen build better networks</description>
	<lastBuildDate>Tue, 27 Jul 2010 22:59:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A simple way to create a Microsoft Word document from a template in Asp.net/C#</title>
		<link>http://blog.stronico.com/2010/07/a-simple-way-to-create-a-microsoft-word-document-from-a-template-in-asp-netc/</link>
		<comments>http://blog.stronico.com/2010/07/a-simple-way-to-create-a-microsoft-word-document-from-a-template-in-asp-netc/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 16:32:52 +0000</pubDate>
		<dc:creator>Steve French</dc:creator>
				<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[ASP.net MVC]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[How To Fix]]></category>

		<guid isPermaLink="false">http://blog.stronico.com/?p=500</guid>
		<description><![CDATA[<p><a title="Will code for food" href="http://www.flickr.com/photos/67523311@N00/114420037/" target="_blank"><img class="alignright" style="border: 0px initial initial;" src="http://farm1.static.flickr.com/45/114420037_f08201d9b8_m.jpg" border="0" alt="Will code for food" width="240" height="180" align="center" /></a> I recently had the need to create a Microsoft Word document from a template.  I initially tried using Office Web Components and Interop but all that really wasn&#8217;t worth the trouble.  I wound up doing global replacements in the html of html   Here is how I did it:</p>
<p><a href="http://blog.stronico.com/2010/07/a-simple-way-to-create-a-microsoft-word-document-from-a-template-in-asp-netc/" class="more-link">Read more on A simple way to create a Microsoft Word document from a template in Asp.net/C#&#8230;</a></p>
<img src="http://blog.stronico.com/?ak_action=api_record_view&#038;id=500&#038;type=feed" alt="" />]]></description>
			<content:encoded><![CDATA[<p><a title="Will code for food" href="http://www.flickr.com/photos/67523311@N00/114420037/" target="_blank"><img class="alignright" style="border: 0px initial initial;" src="http://farm1.static.flickr.com/45/114420037_f08201d9b8_m.jpg" border="0" alt="Will code for food" width="240" height="180" align="center" /></a> I recently had the need to create a Microsoft Word document from a template.  I initially tried using Office Web Components and Interop but all that really wasn&#8217;t worth the trouble.  I wound up doing global replacements in the html of html   Here is how I did it:</p>
<ol>
<li>Open up your template document in word, and put any target areas in special Brackets, the text would read something like &#8220;I, [FULLNAME] do hereby affirm that&#8221;.  I found that the target area had to be in uppercase, I&#8217;m not sure why</li>
<li>Go to &#8220;Save As Html, Filtered&#8221;, and save it in a writeable directory.</li>
<li>In your C# code, first load the entire document into a string</li>
<li>Convert that string into an instance of StringBuilder</li>
<li>Use the StringBuilder Replace function, it would look something like this &#8211;  sb.Replace(&#8220;[FULLNAME]&#8220;, strFullName);</li>
<li>Create a TextWriter, and write the StringBuilder to it &#8211; make sure you&#8217;re saving it with a &#8220;.doc&#8221; extension.</li>
<li>Close the TextWriter</li>
</ol>
<p>All told, the code looks like this</p>
<blockquote>
<div id="_mcePaste">//Create a new filename</div>
<div id="_mcePaste">string strFileName = System.Guid.NewGuid().ToString();</div>
<div id="_mcePaste">string strPathRoot = &#8220;d:\\domains\\MyDomain\\Word\\&#8221;;</div>
<div id="_mcePaste">string strPath = strPathRoot + &#8220;TemplateHtml.doc&#8221;;</div>
<div id="_mcePaste">string str = System.IO.File.ReadAllText(strPath);</div>
<div id="_mcePaste">StringBuilder sb = new StringBuilder();</div>
<div id="_mcePaste">sb.AppendLine(s);</div>
<div id="_mcePaste">//replace the text</div>
<div id="_mcePaste">sb.Replace(&#8220;[FULLNAME]&#8220;, strFullName);</div>
<div id="_mcePaste">//save it out</div>
<div id="_mcePaste">TextWriter tw = new StreamWriter(strPathRoot + strFileName + &#8220;.doc&#8221;);</div>
<div id="_mcePaste">// write a line of text to the file</div>
<div id="_mcePaste">tw.WriteLine(sb.ToString());</div>
<div id="_mcePaste">// close it</div>
<div id="_mcePaste">tw.Close();</div>
<div id="_mcePaste">tw.Dispose();</div>
</blockquote>
<p>That&#8217;s it!</p>
<p><small><a title="Attribution License" href="http://creativecommons.org/licenses/by/2.0/" target="_blank"><img src="http://blog.stronico.com/wp-content/plugins/photo-dropper/images/cc.png" border="0" alt="Creative Commons License" width="16" height="16" align="absmiddle" /></a></small><br />
<small><a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a title="pvera" href="http://www.flickr.com/photos/67523311@N00/114420037/" target="_blank">pvera</a></small></p>
<img src="http://blog.stronico.com/?ak_action=api_record_view&id=500&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.stronico.com/2010/07/a-simple-way-to-create-a-microsoft-word-document-from-a-template-in-asp-netc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Fix: Canonical Urls with IIS 7&#8217;s Url Rewrite feature for https</title>
		<link>http://blog.stronico.com/2010/06/how-to-fix-canonical-urls-with-iis-7s-url-rewrite-feature-for-https/</link>
		<comments>http://blog.stronico.com/2010/06/how-to-fix-canonical-urls-with-iis-7s-url-rewrite-feature-for-https/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 22:24:06 +0000</pubDate>
		<dc:creator>Steve French</dc:creator>
				<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[ASP.net MVC]]></category>
		<category><![CDATA[How To Fix]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://blog.stronico.com/?p=462</guid>
		<description><![CDATA[<p><a title="SATOR Magic square" href="http://www.flickr.com/photos/45035549@N00/287007410/" target="_blank"><img class="alignright" style="border: 0px initial initial;" src="http://farm1.static.flickr.com/119/287007410_3520a789d7_m.jpg" border="0" alt="SATOR Magic square" width="240" height="240" /></a><strong>The Problem:</strong> You want to make your website all SEO friendly by creating a single, canonical url.  For example, if someone types in <a href="http://stronico.com" target="_blank">http://www.stronico.com</a>, you want them to be redirected to <a href="http://stronico.com" target="_blank">http://stronico.com</a> (Google likes it this way).  You do some research and discover that all of the default code and documentation for handling canonical Urls in IIS 7 uses web.config files and the URL Rewrite application program.  All is well and good so far, but what if you use SSL?  The stock code will always redirect you to <a href="https://stronico.com" target="_blank">http://stronico.com/Signup/</a> even if the original url was <a href="https://stronico.com">https://stronico.com/Signup/</a> (note the https).<span id="more-462"></span></p>
<p><a href="http://blog.stronico.com/2010/06/how-to-fix-canonical-urls-with-iis-7s-url-rewrite-feature-for-https/" class="more-link">Read more on How to Fix: Canonical Urls with IIS 7&#8217;s Url Rewrite feature for https&#8230;</a></p>
<img src="http://blog.stronico.com/?ak_action=api_record_view&#038;id=462&#038;type=feed" alt="" />]]></description>
			<content:encoded><![CDATA[<p><a title="SATOR Magic square" href="http://www.flickr.com/photos/45035549@N00/287007410/" target="_blank"><img class="alignright" style="border: 0px initial initial;" src="http://farm1.static.flickr.com/119/287007410_3520a789d7_m.jpg" border="0" alt="SATOR Magic square" width="240" height="240" /></a><strong>The Problem:</strong> You want to make your website all SEO friendly by creating a single, canonical url.  For example, if someone types in <a href="http://stronico.com" target="_blank">http://www.stronico.com</a>, you want them to be redirected to <a href="http://stronico.com" target="_blank">http://stronico.com</a> (Google likes it this way).  You do some research and discover that all of the default code and documentation for handling canonical Urls in IIS 7 uses web.config files and the URL Rewrite application program.  All is well and good so far, but what if you use SSL?  The stock code will always redirect you to <a href="https://stronico.com" target="_blank">http://stronico.com/Signup/</a> even if the original url was <a href="https://stronico.com">https://stronico.com/Signup/</a> (note the https).<span id="more-462"></span></p>
<p><strong>The Cause:</strong> URL Rewrite is new, and it was an oversight on Microsoft&#8217;s part.</p>
<p><strong>The Solution:</strong> You have to use two rules, first checking to see if the url contains the https.  Here is a sample below</p>
<blockquote><p>&lt;rewrite&gt;<br />
&lt;rules&gt;<br />
&lt;rule name=&#8221;Canonical Hostname &#8211; No HTTPS&#8221;&gt;<br />
&lt;match url=&#8221;(.*)&#8221; /&gt;<br />
&lt;conditions logicalGrouping=&#8221;MatchAll&#8221; trackAllCaptures=&#8221;false&#8221;&gt;<br />
&lt;add input=&#8221;{HTTPS}&#8221; pattern=&#8221;OFF&#8221; /&gt;<br />
&lt;add input=&#8221;{HTTP_HOST}&#8221; pattern=&#8221;^stronico\.com$&#8221; negate=&#8221;true&#8221; /&gt;<br />
&lt;/conditions&gt;<br />
&lt;action type=&#8221;Redirect&#8221; url=&#8221;http://stronico.com/{R:1}&#8221; /&gt;<br />
&lt;/rule&gt;<br />
&lt;rule name=&#8221;Canonical Hostname &#8211; With HTTPS&#8221;&gt;<br />
&lt;match url=&#8221;(.*)&#8221; /&gt;<br />
&lt;conditions logicalGrouping=&#8221;MatchAll&#8221; trackAllCaptures=&#8221;false&#8221;&gt;<br />
&lt;add input=&#8221;{HTTPS}&#8221; pattern=&#8221;ON&#8221; /&gt;<br />
&lt;add input=&#8221;{HTTP_HOST}&#8221; pattern=&#8221;^stronico\.com$&#8221; negate=&#8221;true&#8221; /&gt;<br />
&lt;/conditions&gt;<br />
&lt;action type=&#8221;Redirect&#8221; url=&#8221;https://stronico.com/{R:1}&#8221; /&gt;<br />
&lt;/rule&gt;<br />
&lt;/rules&gt;<br />
&lt;/rewrite&gt;</p></blockquote>
<p>That&#8217;s it!  It took me an embarassingly long time to figure that one out.<br />
<small><a title="Attribution License" href="http://creativecommons.org/licenses/by/2.0/" target="_blank"><img src="http://blog.stronico.com/wp-content/plugins/photo-dropper/images/cc.png" border="0" alt="Creative Commons License" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a title="Marco Fedele" href="http://www.flickr.com/photos/45035549@N00/287007410/" target="_blank">Marco Fedele</a></small></p>
<img src="http://blog.stronico.com/?ak_action=api_record_view&id=462&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.stronico.com/2010/06/how-to-fix-canonical-urls-with-iis-7s-url-rewrite-feature-for-https/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fix the No connection could be made because the target machine actively refused it 127.0.0.1:25 error</title>
		<link>http://blog.stronico.com/2010/02/how-to-fix-the-no-connection-could-be-made-because-the-target-machine-actively-refused-it-127-0-0-125-error/</link>
		<comments>http://blog.stronico.com/2010/02/how-to-fix-the-no-connection-could-be-made-because-the-target-machine-actively-refused-it-127-0-0-125-error/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 23:06:56 +0000</pubDate>
		<dc:creator>Steve French</dc:creator>
				<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[ASP.net MVC]]></category>
		<category><![CDATA[How To Fix]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://blog.stronico.com/?p=243</guid>
		<description><![CDATA[<p><strong>The Problem:</strong> You have a brand new Windows 2008 server and you are testing your web application and trying to send an email.  Every time you try to send an email via the web application you get the following error</p>
<p><a href="http://blog.stronico.com/2010/02/how-to-fix-the-no-connection-could-be-made-because-the-target-machine-actively-refused-it-127-0-0-125-error/" class="more-link">Read more on How to fix the No connection could be made because the target machine actively refused it 127.0.0.1:25 error&#8230;</a></p>
<img src="http://blog.stronico.com/?ak_action=api_record_view&#038;id=243&#038;type=feed" alt="" />]]></description>
			<content:encoded><![CDATA[<p><strong>The Problem:</strong> You have a brand new Windows 2008 server and you are testing your web application and trying to send an email.  Every time you try to send an email via the web application you get the following error</p>
<blockquote><p>&#8220;System.Net.Sockets.SocketException: No connection could be made because the  target machine actively refused it 127.0.0.1:25&#8243;</p></blockquote>
<p><strong>The Cause:</strong> SMTP services are not installed on the server, they do not seem to be installed by default.<span id="more-243"></span></p>
<p><strong>The Solution:</strong> SMTP is not configured on the server.  Go ahead and add in SMTP (it is not installed by default).  It will take about 60 seconds to install.  You will then get the error  &#8220;Mailbox unavailable. The server response was: 5.7.1 Unable to relay for user@domain.com&#8221;.  You then must run on the SMTP relaying services via the IIS 6 interface (for some reason) in start/control panel/administrative tools/internet information  services and add the current account from there.</p>
<img src="http://blog.stronico.com/?ak_action=api_record_view&id=243&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.stronico.com/2010/02/how-to-fix-the-no-connection-could-be-made-because-the-target-machine-actively-refused-it-127-0-0-125-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is the best jQuery modal popup method?</title>
		<link>http://blog.stronico.com/2010/02/what-is-the-best-jquery-modal-popup-method/</link>
		<comments>http://blog.stronico.com/2010/02/what-is-the-best-jquery-modal-popup-method/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 21:17:46 +0000</pubDate>
		<dc:creator>Steve French</dc:creator>
				<category><![CDATA[ASP.net MVC]]></category>
		<category><![CDATA[Biz]]></category>
		<category><![CDATA[Stronico]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.stronico.com/?p=207</guid>
		<description><![CDATA[<p>I do not know that much about jQuery, or any of it&#8217;s offshoots (jQueryUI, etc) but I do have a need for modal popups.  As I am building the website in ASP.net MVC, instead of ASP.net webforms I  have decided to use the jQuery platform instead of the standard Ajax Toolkit.</p>
<p><a href="http://blog.stronico.com/2010/02/what-is-the-best-jquery-modal-popup-method/" class="more-link">Read more on What is the best jQuery modal popup method?&#8230;</a></p>
<img src="http://blog.stronico.com/?ak_action=api_record_view&#038;id=207&#038;type=feed" alt="" />]]></description>
			<content:encoded><![CDATA[<p>I do not know that much about jQuery, or any of it&#8217;s offshoots (jQueryUI, etc) but I do have a need for modal popups.  As I am building the website in ASP.net MVC, instead of ASP.net webforms I  have decided to use the jQuery platform instead of the standard Ajax Toolkit.</p>
<p>I have looked over many, many modal popup schemes and decided to use the <a href="http://www.queness.com/post/77/simple-jquery-modal-window-tutorial" target="_blank">Queness modal popup method</a>.  It is  the most usable of the methods I&#8217;ve seen.   Look for it on the <a href="http://www.stronico.com">main Stronico site</a> when it launches!</p>
<img src="http://blog.stronico.com/?ak_action=api_record_view&id=207&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.stronico.com/2010/02/what-is-the-best-jquery-modal-popup-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fix invisible view in ASP.net mvc</title>
		<link>http://blog.stronico.com/2009/12/how-to-fix-invisible-view-in-asp-net-mvc/</link>
		<comments>http://blog.stronico.com/2009/12/how-to-fix-invisible-view-in-asp-net-mvc/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 07:31:00 +0000</pubDate>
		<dc:creator>Steve French</dc:creator>
				<category><![CDATA[ASP.net MVC]]></category>
		<category><![CDATA[How To Fix]]></category>

		<guid isPermaLink="false">http://d841862.test42.slangdatabase.com/2009/12/how-to-fix-invisible-view-in-asp-net-mvc/</guid>
		<description><![CDATA[<p>This is not the most significant I know, but the goal is to document every problem that took more than 15 minutes to solve, and I did try the more complicated methods before I tried the obvious one, so here it is.</p>
<p><span style="font-weight: bold;">The Problem:</span> When programming in ASP.net MVC in Visual Studio 2008 you create a new folder, in the views directory, then create a new view in that directory called Index.  For example I was working on the Stronico public site (coming soon, really) and created a directory called &#8220;Contact&#8221;, and a view called &#8220;Index.aspx&#8221; so the url could be http://www.Stronico.com/Contact/.  I also created the Controller &#8220;ContactController.cs&#8221;.  When I went to the staging site on LocalHost, I got the &#8220;File Not Found&#8221; error.</p>
<p><span style="font-weight: bold;">The Cause:</span> I never did find out.  I tried changing the verbiage slightly, in case contact was a protected word, I reset IIS, I did several other things.  None of the usual methods worked.</p>
<p><span style="font-weight: bold;">The Solution:</span> I finally just closed the solution and restarted it and I was able to get to the contact page.  No idea why that worked, but it did.</p>
<p>Sort of a a lame post, but I did spend slightly more than fifteen minutes trying to see why the page would not appear, only to find it to be a simple Visual Studio error.</p>
<p><a href="http://blog.stronico.com/2009/12/how-to-fix-invisible-view-in-asp-net-mvc/" class="more-link">Read more on How to fix invisible view in ASP.net mvc&#8230;</a></p>
<img src="http://blog.stronico.com/?ak_action=api_record_view&#038;id=38&#038;type=feed" alt="" />]]></description>
			<content:encoded><![CDATA[<p>This is not the most significant I know, but the goal is to document every problem that took more than 15 minutes to solve, and I did try the more complicated methods before I tried the obvious one, so here it is.</p>
<p><span style="font-weight: bold;">The Problem:</span> When programming in ASP.net MVC in Visual Studio 2008 you create a new folder, in the views directory, then create a new view in that directory called Index.  For example I was working on the Stronico public site (coming soon, really) and created a directory called &#8220;Contact&#8221;, and a view called &#8220;Index.aspx&#8221; so the url could be http://www.Stronico.com/Contact/.  I also created the Controller &#8220;ContactController.cs&#8221;.  When I went to the staging site on LocalHost, I got the &#8220;File Not Found&#8221; error.</p>
<p><span style="font-weight: bold;">The Cause:</span> I never did find out.  I tried changing the verbiage slightly, in case contact was a protected word, I reset IIS, I did several other things.  None of the usual methods worked.</p>
<p><span style="font-weight: bold;">The Solution:</span> I finally just closed the solution and restarted it and I was able to get to the contact page.  No idea why that worked, but it did.</p>
<p>Sort of a a lame post, but I did spend slightly more than fifteen minutes trying to see why the page would not appear, only to find it to be a simple Visual Studio error.</p>
<img src="http://blog.stronico.com/?ak_action=api_record_view&id=38&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.stronico.com/2009/12/how-to-fix-invisible-view-in-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
