<?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>Meatball&#039;s Guide to .NET &#187; Tools</title>
	<atom:link href="http://rogerpence.com/blog/index.php/archives/category/tools/feed" rel="self" type="application/rss+xml" />
	<link>http://rogerpence.com/blog</link>
	<description>A dogma-free guide to making real-world sense of .NET</description>
	<lastBuildDate>Wed, 23 Jun 2010 16:15:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Starting Cassini manually</title>
		<link>http://rogerpence.com/blog/index.php/archives/245</link>
		<comments>http://rogerpence.com/blog/index.php/archives/245#comments</comments>
		<pubDate>Sat, 14 Mar 2009 03:36:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://rogerpence.com/blog/?p=3</guid>
		<description><![CDATA[ If you create Web sites with Visual Studio 2005/2008 using the file system, VS&#8217;s intrinsic Web server Cassini is used to host your Web app during development. Cassini is a handy improvement over using IIS for development—if for no other reason that its ability to run your projects without every needing to create a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://rogerpence.com/blog/wp-content/uploads/2009/06/startingcar.jpg"><img style="border-right-width: 0px; margin: 0px 10px 8px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="startingcar" border="0" alt="startingcar" align="left" src="http://rogerpence.com/blog/wp-content/uploads/2009/06/startingcar-thumb.jpg" width="244" height="231" /></a> If you create Web sites with Visual Studio 2005/2008 using the file system, VS&#8217;s intrinsic Web server Cassini is used to host your Web app during development. Cassini is a handy improvement over using IIS for development—if for no other reason that its ability to run your projects without every needing to create a virtual directory. I’ve read some blog posts and other comments on the Web about Cassini causing issues during development. Some insist that it behaves differently than IIS. I have never had any such trouble with Cassini and think its advantages over IIS, at least for initial development, make Cassini worthwhile.</p>
<p>However, there is a minor downside to Cassini: You can&#8217;t run your projects as stand-alone applications. That is, by default Cassini only runs when Visual Studio is running. Traditionally, to get a Web app to run independent of Visual Studio, you&#8217;d need to create an IIS virtual directory. However, if you start Cassini manually, you can avoid the need for IIS for running your ASP.NET projects outside Visual Studio. By the way, do note that when I talk about running your projects independent of Visual Studio, I mean for testing purposes—under no circumstances would you or should you use Cassini as a production Web server. To start Cassini manually, use the DOS command line as shown in Figure 1:</p>
<div class="sourceCodeHeading">Figure 1. DOS command line to start Cassini</div>
<div id="Id1228563750SourceCode" class="sourceCode">
<pre class="even"><span class="ln">  1</span><span class="code"> c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\WebDev.WebServer.EXE </span></pre>
<pre class="odd"><span class="ln">  2</span><span class="code">     /port:8888 /path:&quot;f:\_codewebclasswclist&quot; /vpath:&quot;/wclist&quot; </span></pre>
</div>
<div class="sourceCodeFooter"><a id="Id1228563750SourceCodeToClipboard" class="copyLink" href="javascript:toggleLineNumbers( 'Id1228563750SourceCode' );">Show copy-friendly code</a></div>
<p>where /<em>path</em> indicates the physical path to the Web app and /<em>vpath</em> indicates the virtual path to the Web app. The <em>port</em> can be any value, but do make note of it. You need it to launch the app in your browser. When you start Cassini manually a DOS box appears and is visible while Cassini is running. Minimize this box if you find it annoying. To end Cassini, right-click the Cassini Web server icon in the notification area and select &quot;stop&quot; or just close the DOS box. After starting Cassini, to run your app, start your browser and use a URL as shown in Figure 2:</p>
<div class="sourceCodeHeading">Figure 2. URL to launch Cassini-hosted app</div>
<div id="Id1227380937SourceCode" class="sourceCode">
<pre class="even"><span class="ln">  1</span><span class="code">http://localhost:8888/wclist/listcustomers.aspx</span></pre>
</div>
<div class="sourceCodeFooter"><a id="Id1227380937SourceCodeToClipboard" class="copyLink" href="javascript:toggleLineNumbers( 'Id1227380937SourceCode' );">Show copy-friendly code</a></div>
<p>where the port you specify is the same as the one used to start Cassini. Note that the virtual path name provided (<em>wclist</em>, in this case) must match what you specified with Cassini&#8217;s <em>/vpath</em> argument. One place where this tip is helpful is when testing Web services. In order to test a client a Web service that you&#8217;ve created, that Web server needs to be running. You could start an instance of Visual Studio, and run the service from there, but by starting Cassini manually, you can avoid needing that second instance of Visual Studio. For each Web service project I create, I also create a batch file that starts and runs the Web service for testing—as shown in Figure 3.</p>
<div class="sourceCodeHeading">Figure 3. Batch file to launch Cassini-hosted app</div>
<div id="Id1229382656SourceCode" class="sourceCode">
<pre class="even"><span class="ln">  1</span><span class="code">start http://localhost:8888/wclist/listcustomers.aspx </span></pre>
<pre class="odd"><span class="ln">  2</span><span class="code">C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\WebDev.WebServer.EXE </span></pre>
<pre class="even"><span class="ln">  3</span><span class="code">    /port:8888 /path:&quot;f:\_codewebclasswclist&quot; </span></pre>
<pre class="odd"><span class="ln">  4</span><span class="code">    /vpath:&quot;/wclist&quot; </span></pre>
</div>
<div class="sourceCodeFooter"><a id="Id1229382656SourceCodeToClipboard" class="copyLink" href="javascript:toggleLineNumbers( 'Id1229382656SourceCode' );">Show copy-friendly code</a></div>
<p>Notice that the browser is launched before Cassini is started (using the DOS <em>Start</em> command). This is because the batch file doesn&#8217;t process any lines after launching Cassini until Cassin ends. Generally, because Cassini starts so quickly, even though the browser starts first, the app displays normally in the browser. Occasionally you might have to click &quot;refresh&quot; in the browser is the app failed to load because Cassini took too long to load.</p>
<p><strong>Use a standard TestPublish folder</strong>. You could run launch a Cassini instance over a Visual Studio&#8217;s project working folder, but this would take creating lots of batch files. I use a different strategy. I create a folder called &quot;TestPublish&quot; and then publish the Web site or Web service I want to test to that folder. The contents of this folder are fluid—changing as I&#8217;m in and out of testing various projects. I don&#8217;t care about this, as this folder is only for test purposes. A single batch file to start Cassini over this folder is all I need to run the latest project I&#8217;ve published there (as shown in Figure 4 below). For quick and dirty Web site deployment to the server, the contents of this folder (after local testing is complete) can be XCOPYed to the Web server for testing on the server.</p>
<div class="sourceCodeHeading">Figure 4. Run a Cassini-hosted app from TestPublish folder</div>
<div id="Id1230256718SourceCode" class="sourceCode">
<pre class="even"><span class="ln">  1</span><span class="code">C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\WebDev.WebServer.EXE </span></pre>
<pre class="odd"><span class="ln">  2</span><span class="code">   /port:8888 /path:&quot;f:\TestPublish&quot; /vpath:&quot;/TestPublish&quot; </span></pre>
</div>
<div class="sourceCodeFooter"><a id="Id1230256718SourceCodeToClipboard" class="copyLink" href="javascript:toggleLineNumbers( 'Id1230256718SourceCode' );">Show copy-friendly code</a></div>
]]></content:encoded>
			<wfw:commentRss>http://rogerpence.com/blog/index.php/archives/245/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
