Scott Hanselman

Where are User Tasks from the Task List in Visual Studio.NET Stored?

December 6, '04 Comments [3] Posted in Programming
Sponsored By

I'm not sure why I wanted to know this, but I was looking for where the User Tasks (not the auto-generated Comment Token Tasks) were stored from Visual Studio.NET.

They are stored in the Solution file's (.SLNs) parallel Solution User Options (.SUO) file. This file appears to be OLE Structured Storage, even in Whidbey.

Now I know.

P.S. We, as a policy, don't check either *.SUO files or *.CSPROJ.USER files into source control (we've added them to .CSVIgnore) as they are totally user-specific options and would not only clutter and confused, but potentially share settings and tasks we don't want to share.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Precompile.axd in ASP.NET 1.1 with System.Web.Handlers.BatchHandler: A harbinger of ASP.NET 2.0 left vestigially in 1.1?

December 5, '04 Comments [0] Posted in ASP.NET | HttpHandler
Sponsored By

I'm surprised I'm just now noticing this. Jon Galloway hooked up the apparently unused System.Web.Handler.BatchHandler to an httpHandler and was able to precompile all his .ASPX pages. This could be useful during deployment to catch any goofs in ASPX code. Certainly not something you want on in production lest you be DoS'ed with compilation, but a helpful thing regardless.

To set this up at the machine level, add the following line to the <httpHandlers> section of %windir%\Microsoft.NET\Framework\v1.1.4322\CONFIG\machine.config:

<add verb="*" path="precompile.axd" type="System.Web.Handlers.BatchHandler"/>

To set this up at the application level, add the you'll need to create an httpHandlers section like so: [JonGalloway]

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="precompile.axd" type="System.Web.Handlers.BatchHandler"/>
    </httpHandlers>
  </system.web>
</configuration>

Now playing: Stevie Wonder - As

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Target: Referral Spam in dasBlog

December 4, '04 Comments [1] Posted in ASP.NET | DasBlog | XML
Sponsored By

I've pretty much solved the comment-Spam problem (only one person has voiced their distaste so far) but a recently perusal of my logs and older posts indicated a ridiculous amount of referral spam. 

This is when someone hits a post on your site and has changed/hacked the HTTP Referrer Header to indicate where they came from. If your blog adds this referrer to the page, as most to, you've just linked to Hot Gay Sex (not that there's anything wrong with Hot Sex between consenting adults : ) ) or whatever by their actions.

The story goes when Google comes around, they see that you've linked to them, and they get Google Juice via the Page Rank System.

Not only is this potentially offensive to my readers, it also obscures the posts and comments when they are filled with referrals.

Potential Solutions:

  • Stop printing out referrals on my pages.
    • Personally, I like to see them, and I think they provide value to the reader so they can see other places with information of interest. It also promotes cross-linking between my peer blogs.
  • Modify dasBlog to NOT add icky referrals.
    • This would be idea. However, it will likely be in version 1.7 in some way, either via James Snape's whitelist solution (I think a whitelist removes the point of referrals, and I'll greatly prefer a keyword-based black list) or some other technique.
    • I've avoided running a "private build" of dasBlog so far (as evidenced by my care in creating the CAPTCHA solution without recompiling) and I'd to continue as such
  • Clean the .xml files occasionally with a process
    • This is quick, easy, can be automated, and will work in the short term for me as I await dasBlog 1.7.

So, here was an opportunity to use the only dev stuff I have on my home machine, Visual Studio C# 2005 Express

Here's what I did. Use at your own risk, back up your /content directory, and know that this will only have to run on your "*.dayextra.xml" files from dasBlog. No error handling, no warrenty, but it worked for me. Enjoy.

Usage: TrackingFilter "c:\yourdasblogcontentdirectory"

File Attachment: TrackingFilter.zip (9 KB) (for VS.NET 2005, I don't know if it works in 2003)

WARNING: The words I put in the .config file are ; delimited and are unquestionably offensive. Not only do they include most of George Carlin's words but they also include "bloglines" and "artima" because they don't provide a value in my referral list.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

GUI Front End to Chris Sells' XmlPreCompiler - For Debugging XmlSerialization Errors

December 3, '04 Comments [0] Posted in ASP.NET | XmlSerializer | Bugs | Tools
Sponsored By

I spend a lot of time with the XmlSerializer (I personally dig it immensely, and I think too many people complain about it, but anyway) and while I put up an article on how to debug directly into the generated assemblies, I noticed that Mathew Nolton has a GUI Front-End to Chris's XmlSerializerPreCompiler.

The tool will check to see if a type can be serialized by the XmlSerializer and shows any compiler errors that happen behind the scenes. +1 for Useful, thanks Chris and Mathew.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

HTTP POSTs and HTTP GETs with WebClient and C# and Faking a PostBack

December 3, '04 Comments [5] Posted in ASP.NET | ViewState | Tools
Sponsored By

A fellow emailed me wanting to screen scrape, er, ah, harvest a page that only displays the data he wants with a postback.

Remember what an HTTP GET looks like under the covers:

GET /whatever/page.aspx?param1=value&param2=value

Note that the GET includes no HTTP Body. That's important. With a POST the 'DATA' moves from the QueryString into the HTTP Body, but you can still have stuff in the QueryString.

POST /whatever/page.aspx?optionalotherparam1=value
Content-Type: application/x-www-form-urlencoded
Content-Length: 25
param1=value&param2=value

Note the Content-Type header and the Content-Length, those are important.

A POST is just the verb for when you have an HTTP document. A GET implies you got nothing.

So, in C#, here's a GET:

public static string HttpGet(string URI)
{
   System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
   req.Proxy = new System.Net.WebProxy(ProxyString, true); //true means no proxy
   System.Net.WebResponse resp = req.GetResponse();
   System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
   return sr.ReadToEnd().Trim();
}

Here's a POST:

public static string HttpPost(string URI, string Parameters)
{
   System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
   req.Proxy = new System.Net.WebProxy(ProxyString, true);
   //Add these, as we're doing a POST
   req.ContentType = "application/x-www-form-urlencoded";
   req.Method = "POST";
   //We need to count how many bytes we're sending. Post'ed Faked Forms should be name=value&
   byte [] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
   req.ContentLength = bytes.Length;
   System.IO.Stream os = req.GetRequestStream ();
   os.Write (bytes, 0, bytes.Length); //Push it out there
   os.Close ();
   System.Net.WebResponse resp = req.GetResponse();
   if (resp== null) return null;
   System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
   return sr.ReadToEnd().Trim();
}

I could and should have put in more 'using' statements, but you get the gist. And, there are other ways to have done this with the BCL, but this is one.

Now, how would you fake an HTTP PostBack? Use a tool like ieHttpHeaders to watch what a real postback looks like, and well, fake it. :) Just hope they don't require unique/encrypted ViewState (via ViewStateUserKey or EnableViewStateMac) for that page, or you're out of luck.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.