<feed version="0.3" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns="http://purl.org/atom/ns#" xml:lang="en-US"><title>/Dan/.NET - Dan Robey's .NET Dumping Spot</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/default.aspx" /><tagline type="text/html">IESL Software</tagline><id>http://blogs.mit.edu/CS/blogs/dsrobey/default.aspx</id><author><url>http://blogs.mit.edu/CS/blogs/dsrobey/default.aspx</url></author><generator url="http://communityserver.org" version="1.1.0.50615">Community Server</generator><modified>2003-12-04T14:13:00Z</modified><entry><title>Wrapping evil text from users</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2009/02/17/69525.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:69525</id><created>2009-02-17T23:53:00Z</created><content type="text/html" mode="escaped">On the web, when display text users enter, there's always the chance someone will be evil and type in a really long url, or fill the textbox with a thousand letter Ws.&amp;nbsp; In the past, I've written functions to take a piece of text and insert spaces in words it finds that are longer than x characters.&amp;nbsp; That sometimes ends up looking silly, because you don't always know how big your display area will be and you're left with extra spaces.&amp;nbsp; I tried to check the big players and see what their solution was.&lt;br&gt;&lt;br&gt;WBR seems to be the default in how to display the text and get away with it.&amp;nbsp; It won't validate with xhtml validators, but it will &lt;a href="http://www.quirksmode.org/oddsandends/wbr.html"&gt;work&lt;/a&gt;.&amp;nbsp; A completely unscientific study shows that google and facebook both use it to cut text automatically.&amp;nbsp; And best of all, if you highlight and cut/paste the text, it doesn't have spaces in it like the &lt;a href="http://www.matsblog.com/stories/778902/"&gt;other solutions&lt;/a&gt; that use a span with a space with a font size of 0.&amp;nbsp; If you use that method, accessibility goes down a bit.&amp;nbsp; &lt;br&gt;&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=69525" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=69525</wfw:commentRss></entry><entry><title>CreateDebate</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2008/04/24/Online_Debating.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:67639</id><created>2008-04-24T17:51:00Z</created><content type="text/html" mode="escaped">I've been helping some friends with a website recently and it's just entered a public beta.&amp;nbsp; &lt;a href="http://www.createdebate.com/"&gt;CreateDebate.com&lt;/a&gt;
is an online debating community that lets users make new open debates
and see what people think about issues.&amp;nbsp; Check it out, it's easy to
create new debates and arguments and check out where everyone stands.&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=67639" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=67639</wfw:commentRss></entry><entry><title>removing designer files from template</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2008/04/24/remove_designer_files_from_visual_studio_templates.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:67637</id><created>2008-04-24T17:25:00Z</created><content type="text/html" mode="escaped">I've gotten fed up with designer files when I'm doing development, so I removed them from my "add item" templates.&amp;nbsp; I basically followed the instructions at &lt;a href="http://davidhayden.com/blog/dave/archive/2005/11/05/2556.aspx"&gt;dave hayden's blog&lt;/a&gt; with a few added quirks.&amp;nbsp; That means edit the files inside the relevant zip in C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp\1033&amp;nbsp; That deals with removing "partial" from the file and setting AutoEventWireup="false" which makes stuff slightly quicker in production.&amp;nbsp; To actually remove a file from the template, you have to delete the lines from the .vstemplate file, otherwise Visual Studio will complain that it's missing.&amp;nbsp; Then you should just have to restart Visual Studio and it should load up.&lt;br&gt;&lt;br&gt;While I was experimenting, I ended up messing up my templates, which was painful to fix, so if that happens, the solution is to open a .NET command prompt (it's in the start menu next to Visual Studio under Visual Studio-&amp;gt;tools) and type in:&lt;br&gt;&lt;strong&gt;devenv /installvstemplates&lt;br&gt;&lt;/strong&gt;If that doesn't work, here are some other options to &lt;a href="http://geekswithblogs.net/ehammersley/archive/2005/11/08/59451.aspx"&gt;reset or reload your visual studio templates&lt;/a&gt;.&lt;br&gt;&lt;strong&gt;&lt;br&gt;&lt;/strong&gt;&lt;a href="http://davidhayden.com/blog/dave/archive/2005/11/05/2556.aspx"&gt;&lt;/a&gt;&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=67637" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=67637</wfw:commentRss></entry><entry><title>link to every page in a .net project</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2005/08/19/17810.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:17810</id><created>2005-08-19T22:13:00Z</created><content type="text/html" mode="escaped">I wanted to print out a list of links to every page in a c#/ASP.NET project to check that they all looked correct.  The caveats: the namespace needs to be the same as the IIS virtual directory for the links to work.  We first get a list of all classes that are derived from System.Web.UI.Page, then Response.Write links to each of them:&lt;br /&gt;&lt;br /&gt;

			System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();&lt;br /&gt;
			foreach(System.Type type in a.GetTypes())&lt;br /&gt;
			{&lt;br /&gt;
				if(type.IsClass &amp;amp;&amp;amp; type.IsSubclassOf(typeof(System.Web.UI.Page)))&lt;br /&gt;
				{&lt;br /&gt;
					string page = type.ToString().Substring(4).Replace(".","/")+".aspx";&lt;br /&gt;
					Response.Write("&amp;lt;a href="\"/"+page+"\""&amp;gt;"+type.ToString()+"&amp;lt;/a&amp;gt; ");&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=17810" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=17810</wfw:commentRss></entry><entry><title>strange .net special character quirk</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2005/08/02/17094.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:17094</id><created>2005-08-02T21:52:00Z</created><content type="text/html" mode="escaped">Apparently doing String.IndexOf("special character") might not always work as you expect it.  The æ character is found in the string "ae" Test yourself by dropping this into a .aspx page:&lt;br /&gt;&lt;br /&gt;  
&amp;lt;% if("ae".IndexOf("æ") == 0) {Response.Write("why?");}%&amp;gt;
&lt;br /&gt;&lt;br /&gt;
I don't really understand why it works that way, but the workaround for this is to use .IndexOf(char) instead:&lt;br /&gt;
&amp;lt;% if("ae".IndexOf('æ') == -1) {Response.Write("all is well in the world");}%&amp;gt;&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=17094" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=17094</wfw:commentRss></entry><entry><title>firefox/IE ASP.NET textbox</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2005/04/11/10245.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:10245</id><created>2005-04-11T19:41:00Z</created><content type="text/html" mode="escaped">Just in case anyone else ever has this problem, the asp:textbox in ASP.NET has the two width properties "Width" and "Columns"  if you want to set the width of a textbox to a certain size so it will display correctly across browsers, both width and columns must be set.  Internet Explorer uses the width field to display on a pixel basis, and firefox uses the "size" attribute which Columns will set when rendered.  If you set one and not the other, the textbox width will be the correct size in one but not the other.
&lt;br /&gt;&lt;br /&gt;
Also remember that using the autoindent function in Visual Studio 2003 with inline imperatives will add tabs which IE sometimes sees as extra spaces, screwing up precision page layouts, especially around TD elements.&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=10245" width="1" height="1"&gt;</content><slash:comments>1</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=10245</wfw:commentRss></entry><entry><title>random ascii generator</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2005/02/08/5989.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:5989</id><created>2005-02-08T19:52:00Z</created><content type="text/html" mode="escaped">I needed to test an ecryption routine over a large amount of text, so I came up with this quick/dirty c# code to generate random (english/code) ascii text.  If you need to test with long strings, you should use a stringbuilder instead of normal string objects:
&lt;br /&gt;&lt;br /&gt;
System.Random rng;&lt;br /&gt;
string GenerateRandomText(int length)&lt;br /&gt;
{&lt;br /&gt;
	string retstr = "";&lt;br /&gt;
	if(null == rng)&lt;br /&gt;
		rng = new System.Random();&lt;br /&gt;
	for(int i=0;i&amp;lt;length;i++)&lt;br /&gt;
	{&lt;br /&gt;
		// good ascii vals between 32 - 126&lt;br /&gt;
		retstr += (char)(rng.Next(127-32)+32);&lt;br /&gt;
	}&lt;br /&gt;
			return retstr;&lt;br /&gt;
}&lt;br /&gt;&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=5989" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=5989</wfw:commentRss></entry><entry><title>find which validator's not working</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2004/10/16/1099.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:1099</id><created>2004-10-16T21:36:00Z</created><content type="text/html" mode="escaped">sometimes you get a validator that's screwing up Page.IsValid, but it doesn't show text for some reason. Here's how I find it:
&lt;br /&gt;&lt;br /&gt;
foreach(BaseValidator b in Page.Validators)&lt;br /&gt;
{&lt;br /&gt;
if(!b.IsValid)&lt;br /&gt;
	Response.Write(b.Text+":"+b.ErrorMessage);&lt;br /&gt;
}&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=1099" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=1099</wfw:commentRss></entry><entry><title>embedded windows forms</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2004/07/07/669.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:669</id><created>2004-07-07T16:03:00Z</created><content type="text/html" mode="escaped">The steps (hopefully)to making a windows form into an embedded internet object:&lt;br /&gt;
1: make the solution compile as a class library&lt;br /&gt;
2: delete the entry point (main())&lt;br /&gt;
3: have your class inherit from a userControl&lt;br /&gt;
4: compile into a .dll&lt;br /&gt;
5: drop the .dll into a virtual directory
6: create a reference to the class in a html file in a virtual directory&lt;br /&gt;
7: adjust security access in directory and through IIS&lt;br /&gt;
8: ?&lt;br /&gt;&lt;br /&gt;
Did I miss anything?&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=669" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=669</wfw:commentRss></entry><entry><title>excellent ws-security reference</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2004/04/26/547.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:547</id><created>2004-04-27T00:10:00Z</created><content type="text/html" mode="escaped">Good reference on &lt;a href="http://msdn.microsoft.com/webservices/building/wse/default.aspx?pull=/library/en-us/dnwse/html/wssecdrill.asp"&gt;Web Services Security Drilldown&lt;/a&gt; for anyone interested in how to programmatically manipulate the WS proxy to provide security using WSE2.  &lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=547" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=547</wfw:commentRss></entry><entry><title>XAML layers</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2004/04/26/546.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:546</id><created>2004-04-26T16:26:00Z</created><content type="text/html" mode="escaped">What have people heard about the new &lt;a href="http://msdn.microsoft.com/Longhorn/understanding/pillars/avalon/default.aspx"&gt;Avalon&lt;/a&gt; / &lt;a href="http://weblogs.asp.net/autocrat/archive/2004/04/05/107488.aspx"&gt;XAML&lt;/a&gt; programming practice MS seems to be pushing?  To me it seems almost parallel to the Java/Javascript division, with new twists thrown in.  What it promises (if it is integrated into IE as I think it will be) is a programming environment in which rich media applications similar to flash can be thrown onto a website and be dynamically loaded into a sandboxed environment on the client side.  If we think about the push to portal systems and the internet as storage space, this is a big step in that direction.  Pieces of software can be loaded and unloaded, taking advantage of web services to provide local/networked actions.  Think of a networked MATLAB where you interact through a local presentation layer while all the number crunching is done by server farms.  In theory, you could make an entire networked operating system using this stuff&lt;br /&gt;&lt;br /&gt;
Dividing presentation and implementation is something we've been trying to do for a long time, but this seems to even more strongly enforce it.  Talk about Macromedia providing a development environment for the presentation layer would make the top layer even slicker, while the implementation is done through "partial classes."  This means not having to learn the strange flash hooks for web services but still being able to integrate rich displays with solid framework.&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=546" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=546</wfw:commentRss></entry><entry><title>dynamic pictures</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2004/04/24/544.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:544</id><created>2004-04-24T23:14:00Z</created><content type="text/html" mode="escaped">&lt;p&gt;I was thinking about how to get around the limitations some sites have on the http-referer for pictures (mostly webcomics that don't want deep linking of pics), and I came up with an interesting idea. Using the strange qualities of Response.Write() and Response.End(), I made a page which takes as input which picture it should get (does a n-1 tier lookup for the http-referer, other info), and then downloads that picture and serves it to the client.&lt;br /&gt;&lt;br /&gt;Confused? You should be. Since I whipped it up in about ten minutes, the code's not the cleanest, but it'll give the basic idea:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;if("pic".Equals(Request.Params["pic"])) {&lt;br /&gt;System.Net.WebClient wc = new System.Net.WebClient();&lt;br /&gt;wc.Headers.Add("Referer","http://rx7.mit.edu");&lt;br /&gt;string newimage = this.Server.MapPath(".")+"\\pics\\"+System.Guid.NewGuid().ToString();&lt;br /&gt;wc.DownloadFile("http://rx7.mit.edu/help.gif", newimage);&lt;br /&gt;Response.WriteFile(newimage);&lt;br /&gt;Response.End();&lt;br /&gt;System.IO.File.Delete(newimage);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;So the image reference looks like &amp;lt;img src=“$page?pic=pic“&amp;gt;, where $page is your web app's address.&lt;br /&gt;Instead of downloading the picture from somewhere, it could be dynamically created, using all of .NET's image manipulation libraries, say, to show the time, or some graphic representation of any data .net handles.  Or do checking before serving an image to see if the user has correct permissions.  Anything your heart desires.&lt;/p&gt;&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=544" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=544</wfw:commentRss></entry><entry><title>back on top</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2004/01/04/493.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:493</id><created>2004-01-04T06:32:00Z</created><content type="text/html" mode="escaped">I finally beat out that other dan robey for first place in the google search for dan robey.  I'm glad that my name is associated with me, and not with someone selling tired self-help ideas.  I guess that means I'll have to do updates more often though, to keep my google karma high.&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=493" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=493</wfw:commentRss></entry><entry><title>Exceptions- use them!</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2003/12/08/484.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:484</id><created>2003-12-08T07:20:00Z</created><content type="text/html" mode="escaped">I am annoyed. I am extremely annoyed. I have just taken an hour to debug an error which did not exist. I downloaded the source code for the newest taxi server for 1.124. Installed, set permissions, etc. When I hit the server, it froze. ASPNET went to 99% and never came back. Browsed through the code a bit, it all looked reasonable, figured it was my fault. Did windows update, and .NET framework SP2 doesn't seem to be installing, or maybe it is, but it never seems to figure out that it's already there.&lt;br /&gt;&lt;br /&gt;After about an hour of reinstallation, etc. I debugged the code a little more. I found that the file wasn't loading. And I had no clue. Why? Because someone had commented out a catch statement which would have thrown the error my way. I have just wasted an hour I could be programming a DFS strategy engine on finding a permissions error. (Yes, even when “Everyone” can read a file, that still doesn't mean ASPNET can).  This innocuous little snippet of code went:&lt;br /&gt;&lt;br /&gt;catch&lt;br /&gt;{&lt;br /&gt;//throw(ea);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;why? What is the purpose of a catch statement if not to give some user feedback about why something has gone wrong. I don't write perfect code. You don't write perfect code. Nobody writes perfect code. That's why exceptions should be caught and some feedback given. &lt;u&gt;Always&lt;/u&gt;. Please, for the children's sake, catch the exceptions and give feedback.&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=484" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=484</wfw:commentRss></entry><entry><title>dealing with long queries</title><link rel="alternate" type="text/html" href="http://blogs.mit.edu/CS/blogs/dsrobey/archive/2003/12/04/483.aspx" /><id>dea6705e-d99c-4a22-9533-aabb455eb28d:483</id><created>2003-12-04T19:13:00Z</created><content type="text/html" mode="escaped">One of the problems with long web queries is user feedback.  If a SQL command takes seconds or even minutes to complete, or if some other heavy processing must be done, users must wait idly as the status bar creeps along, blindly guessing at how long the response will take.&lt;br /&gt;&lt;br /&gt;
This problem is a general notification problem with web queries which stem from the nature of stateless http client/server protocol.  A possible solution is to place a layer of indirection on anticipated long queries.  Using the web service model, the indirection layer (call it the foyer layer) does the standard query asynchronously, and instead of sending the results, sends a java refresh page, which causes the client to requery the foyer layer every &lt;i&gt;n&lt;/i&gt; seconds.  The foyer layer can hold data about the current query, including what percent is done.  This can be relayed from individual calls, if using SQL can be updated after each SQL statement in the long SQL stored procedure, or previous long calls can be used as an estimation metric.  The data can be used to update a true status bar on the page while serving other information to the client - funny quotes, relevant advertising, customer feedback, etc.&lt;br /&gt;&lt;br /&gt;
The foyer layer can be programmed in any language, and one method which comes to mind would be the recent Shockwave web services, which allow for a stateful client.&lt;img src="http://blogs.mit.edu/CS/aggbug.aspx?PostID=483" width="1" height="1"&gt;</content><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.mit.edu/CS/blogs/dsrobey/commentrss.aspx?PostID=483</wfw:commentRss></entry></feed>