If you use URL rewriting in your ASP.NET apps you’re probably familiar with the workarounds required to get your rewritten URL to show up in the action attribute of the form on your pages (see ScottGu’s ‘Handling ASP.NET PostBacks with URL Rewriting’). Well, no more.
Included in the latest ASP.NET Service Pack is this gem (via Scott Hanselman):
HtmlForm.Action is now settable - Again, subtle, but very cool. I like to use URL rewriting a lot and want my <form action=”"> to be a certain way. Now I can set it manually without fooling around with RegEx’s and messing with the whole response.
Woot! I deleted my FormRewriter.cs control adapter and .browser file then added this little snippet to my common BasePage (you can do this in either Page_Init or Page_Load on individual pages) and now my form action attributes reflect the original URL.
// header is created by Ionic’s ISAPI Rewrite Filter (IIRF) string u = Request.Headers["X-Rewrite-Url"]; if (!string.IsNullOrEmpty(u)) { Form.Action = u; }
Automatic properties are nice, but sometimes you just want a good ol’ regular property with a backing field. Visual C# 2005 had the ‘prop’ code snippet which generated this:
Visual C# 2008 now generates the following when using the ‘prop’ snippet:
I find myself wanting to use the old snippet more than the new one, so I went into the 2005 code snippets, copied the ‘prop’ snippet file, made a few changes and imported it into 2008 (Tools | Code Snippets Manager | Import).
Visual Studio feature request o’ the day: ‘Surround With’ in the HTML editor (highlight some HTML, hit Ctrl-K, Ctrl-S, type an HTML tag like ‘div’, press enter). Anyone know if this exists or not? How difficult would it be to write a VS add-in to make it happen?
Lately (while not blogging) I’ve been thinking of things I’d really like to blog about but haven’t made the time for. Here they are:
jQuery I hate JavaScript. jQuery changes everything though. I can actually be a functional JavaScript programmer. I particularly like how you can attach events without overloading your code with onclick="" everywhere. I got hooked on jQuery for UI bits (especially the tablesorter and tabs plugins), but I’m becoming obsessed with it because of the sweet Ajax functions. jQuery + ASP.NET AJAX PageMethods is teh awesome (minus the HUGE ASP.NET AJAX script handlers). I’ve also been pondering using jQuery for a light-weight faux-UpdatePanel setup (similar to this). You may hear more about this in the future.
SubSonic I can’t really add anything to the SubSonic conversation that you probably haven’t heard before so I’ll keep this section short. The unofficial MVC templates have made their way into a ton of my projects. I’m psyched for version 2.1 codename "Pakala" and the new, officially-supported Repository Pattern to replace the MVC templates.
Flee I have an extremely fun project that’s heavily using Flee but unfortunately, that’s still under wraps for the time being.
Super Mario Galaxy You can’t work all the time! This is the most fun I’ve ever had playing a game. I usually stick to sports games, but this game is incredible. It will redefine what you know about Mario and platformers.
Jing Project I can’t believe I hadn’t heard about this before today. I was looking for a way to more easily take screengrabs (without spending any money) when I came across TechSmith’s Jing Project. Jing is a dead simple way to share screengrabs and even simple screencasts. The interface is exceptional and the service works great from capture to uploading. Here’s hoping they keep it free!
MozyPro Cheap, instant off-site back up. Takes the work out of backing up.
I’ve been running VS2008 Pro Beta 2 for awhile and had mostly good luck with it. There were only two recurring bugs that got to be annoying. The first was that after typing CssClass or class in the HTML source editor and hitting ‘=’ the automatic quotes (which I enabled in the settings) would be doubled so auto-complete would generate CssClass="""" instead of CssClass="". I found the bug in Connect and MS said it would be resolved in RTM.
The other bug popped up when I double-clicked a .aspx file in the solution explorer while the corresponding .aspx.cs file was already open. I’d get an "This document is opened by another project." error dialog but the file would open normally. I never took the time to track that bug down in Connect.
Today I download the RTM bits and the first bug still exists in a way. Now I don’t get any automatic quotes (I doublechecked that its enabled) for CssClass/class. So now on auto-complete I get CssClass= or class=. All other attribute names generate the auto quotes, even nonsense words. I reset my Visual Studio settings to the defaults and I still get the error.
As for the second bug, it still exists. I thought it might be VisualSVN causing it but the dialog title is "Microsoft Visual Studio" and it happens with web sites that aren’t in SVN.
Neither bug is a showstopper, but they are very aggravating. Is anyone else experiencing these issues?
UPDATE: The first bug only happens if you have no styles defined in your document or a linked stylesheet OR if VS hasn’t yet parsed your linked styles (it can take a few seconds after loading a document). Still annoying if you’re working on a new document and haven’t defined any styles yet. The second bug appears to be an issue with one of my add-ons as I was unable to replicate it on another machine. I don’t know which add-on yet.
UPDATE 2: MS was able to replicate the first bug and is going to fix it for a future release (thanks to the guys on the Web Dev Tools team for their quick and helpful responses!). After uninstalling all my add-ins, I narrowed the second bug down to VisualSVN and have contacted them to let them know.
I came across a great free add-in for Visual Studio 2005 called SonicFileFinder. The premise is simple, hit a hotkey and a popup (or tool window if you prefer) displays all the files in your project. Type the name, hit enter and the file comes up in the editor. The interface is clean and overall works a lot better than the other add-in I had been using for this. The only thing missing is a class browser, but I rarely use that since my filenames reflect the classes contained in them.
I’m going to be compiling my list of favorite development tools and add-ins in the near future so check back for that.
FULL DISCLOSURE: I was inspired to write this mini review because of an offer by the maker of this software for a free license for blogging about their software (the offer is posted on the front page of their web site). Below is an unbiased review (you’ll have to take my word for it).
I was looking through the programming section of Digg today and came across Dispatch for ASP.NET by Yellow Cup. Having found myself frequently frustrated with Visual Studio 2005’s “Copy Web Site” function, I thought I’d give it a try.
The Good
Setup was straightforward and painless. Dispatch adds a tab to your Visual Studio environment and lists the projects in your solution. After entering FTP information to configure the site for deployment, you’ll see all the files in your web site. Checking the box next to a file marks it for upload. By default, it will also mark any changed files for upload as well. There’s built-in filtering to ignore files you don’t want uploaded (e.g. solution/project files, etc.). The integration into VS is seemless and intuitive. The “Remote View Overlay” feature is excellent for showing you what does and doesn’t exist locally and remotely (in my opinion, this feature should be on by default).
The Bad
Accessing some of the features isn’t exactly clear at first (you have to right click on the site…toolbar buttons would make more sense and be more discoverable). If you run a compare and a large number of items get checked and you try to uncheck them from the top level, it can take awhile and there’s no status update so it looks like VS is hung up. The “Compare Against Local” and “Compare Against Server” functions seem redundant when Remote View Overlay is on (and are poorly named). And lastly, there’s no support for precompiled sites (ala Web Development Projects which is my typical deployment method).
Conclusion
If you want a better FTP function right in Visual Studio 2005 and you don’t precompile your sites before deployment, I’d give Dispatch a try. It’s currently in beta and will cost $14.95 when the final version is released.