About/Contact

Steve Trefethen

Steve Trefethen is CTO at Wanderful Media.
Contact me

View my LinkedIn profile



Calendar

<<  June 2013  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar

Disclaimer

The posts on this weblog are provided AS IS with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.



Properties of a webform causing inline errors using <%= %> style markup

December 22 2010 11:43AM

I’ve been looking at the latest Facebook Developer Toolkit samples and tried to add a property to the Default.aspx.cs using the IFrame sample application like this:

<%=this.MapCanvas %>

Which yielded this error:

Error    28    'ASP.default_aspx' does not contain a definition for 'MapCanvas' and no extension method 'MapCanvas' accepting a first argument of type 'ASP.default_aspx' could be found (are you missing a using directive or an assembly reference?)    C:\Users\SteveT\Documents\Visual Studio 2010\WebSites\FBIFrame\Default.aspx    38    17    C:\...\FBIFrame\

The problem is that the @Page tag reads:

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/IFrameMaster.Master" CodeBehind="Default.aspx.cs" Inherits="IFrameSample.Default" %>

Changing CodeBehind to CodeFile gets things working.

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/IFrameMaster.Master" CodeFile="Default.aspx.cs" Inherits="IFrameSample.Default" %>
FacebookDel.icio.usDigg It!

Google Map Facebook Application written in ASP.NET

December 14 2010 12:52AM

Back in April of 2009 I wrote a post about a Facebook application named SocialMine. It basically plots your social network on a map based on information for your network using $g(FQL queries). I'm writing this post because I've recently tweaked the application to correct a problem where the vast majority of your friends didn't appear on the map. Initially, I was thinking the issue was related to all of the $g(Facebook profile privacy concerns) from the last 18+ months though it turns out the code I wrote to parse the results for use in a $g(Simile Exhibit) was failing. Facebook changed the results for current_location which broke my code, a problem that's now fixed. Despite the fix a user commented that they couldn't see any of their friends on the map and after a little digging I discovered that he wasn't getting any geographic information back for any of his friends. Using my ASP.NET Facebook Starter Application I suggested he try few queries using the FQL page so he could debug what's being returned. I thought I post the same steps here in case anyone wants to review their own FQL data.

  • Add facebookaspnet (another application of mine) to your account.
  • Once in that application click on the FQL link at the top which will take you to a page where you can execute FQL queries.
  • Paste this FQL statement into the edit box substituting your UID (provided on the page):
    SELECT name,current_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 =<uid> )
  • Check the "Use JSON" option
  • Click the Execute button and check to see if the location data is null
  • SocialMine application profile page
SocialMine also makes use of this HttpHandler for processing FQL queries.
FacebookDel.icio.usDigg It!

Invalid Parameter Error using Facebook Developer Toolkit 1.6

May 29 2008 6:49AM

[UPDATE: June 3, 2008] Problem solved.
I’ve been playing with a Facebook Application started using my Facebook Developer’s Toolkit Starter Kit (for v1.6) and I’m seeing an "Invalid Parameter" error which occurs if the application is left idle in the browser then an attempt is made to interact with the app and the session times out. The error is as follows:

Server Error in '/FacebookASPNET' Application.

Invalid parameter

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Facebook.Exceptions.FacebookException: Invalid parameter

Source Error:

Line 32:   else if (!String.IsNullOrEmpty(authToken))
Line 33:   {
Line 34:       _fbService.CreateSession(authToken);
Line 35:       Session["facebook_session_key"] = _fbService.SessionKey;
Line 36:       Session["facebook_userId"] = _fbService.UserId;

Source File: e:\web\nnn\htdocs\FacebookASPNET\Default.aspx.cs    Line: 34

Stack Trace:

[FacebookException: Invalid parameter]
   Facebook.API.FacebookAPI.ErrorCheck(XmlDocument doc) +900
   Facebook.API.FacebookAPI.LoadXMLDocument(String rawXML) +127
   Facebook.API.FacebookAPI.CreateSession() +92
   Facebook.Components.FacebookService.CreateSession(...) +37
   _Default.Page_Load(...) in Default.aspx.cs:34
   System.Web.Util.CalliHelper.EventArgFunctionCaller(...) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(...) +33
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(...) +1436


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

The problem is discussed on the Facebook Developer’s Wiki here with the solution being to add the following code to allow for an IE issue regarding pages loaded in a frame from a different domain:

protected override void OnPreRender(EventArgs e) { Response.AppendHeader("P3P", "CP=\"CAO PSA OUR\""); base.OnPreRender(e); }

I’ve gone ahead and added this to my application but I’m still seeing this error. There are a number of discussions on the CodePlex project pages for the Toolkit related to this error message but AFAICT, it doesn’t appear this has been resolved at least not for IFRAME applications. In fact, the last message in this thread on the subject a user mentions switching to Facebook.NET which apparently doesn’t exhibit the same behavior. I haven’t had a chance to debug this further as I’m swamped with other work right now however, I thought it might be worth posting about to start gathering information about it. I’ll probably throw together a quick test using Facebook.NET for comparison and see what happens.

Anyway, have you run into this problem? Did the OnPreRender solution work? I’d like to update the starter kit as necessary to resolve this issue so if you have any details please let me know. Thanks!

FacebookDel.icio.usDigg It!

Tags: ,

URL rewriting in ASP.NET and web.config settings

April 21 2008 4:27PM

The other day I blogged about potentially switching to blogengine.net but one of the major issues is ensuring the URL’s I have in dasBlog either continue to work or redirect accordingly. To that end, I started investigating URL rewriters for ASP.NET and found this post of ScottGu’s very helpful. He mentioned two different Open Source rewriters and I opted for UrlRewriter.net which describes itself as:

UrlRewriter.NET is an open-source, light-weight, highly configurable URL rewriting component for ASP.NET 1.1 and 2.0. UrlRewriter.NET provides similar IIS Rewrite capabilities that the Apache web server provides with mod_rewrite and .htaccess. You don’t need to install an ISAPI Rewrite filter to use the component. Best of all, UrlRewriter.NET is free and licensed with a very permissive MIT-style licence.

I found it to be all of the above and the install/configuration to be very straightforward not to mention it has good online help and a support forum.

One caveat that I ran into though was that once installed at the root I started seeing this error in my other ASP.NET applications:

Server Error in '/blog' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly 'Intelligencia.UrlRewriter' or one of its dependencies. The system cannot find the file specified. (E:\web\xxxxxxx\htdocs\web.config line 11)

Source Error:

Line 9:    <system.web>
Line 10:     <httpModules>
Line 11:       <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, 
Intelligencia.UrlRewriter" />
Line 12: </httpModules> Line 13: </system.web>

Source File: E:\web\xxxxxxxx\htdocs\web.config    Line: 11


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

The Fix

To fix this I added the following to the web.config files of my other ASP.NET applications removing the new assembly dependency:

1 <system.web> 2 <httpModules> 3 <remove name="UrlRewriter" /> 4 </httpModules> 5 </system.web>

If you’re aware of other options that don’t require changes to every web.config I’d love to hear about them. At any rate, while I haven’t decided to switch blog engines yet I now have the pieces in place to do just that.

What do you use for URL rewriting particularly in a hosted environment?
FacebookDel.icio.usDigg It!

Facebook Starter Kits for VS.NET updated

January 15 2008 7:41AM
Since I’ve had a lot of interest in the VS.NET Starter Kits I created for the Facebook development I thought it worth mentioning I’ve updated both to their latest releases.

Facebook Developer ToolKit is now at v1.5 (starter kit download)

Facebook.NET is now at v0.3 (starter kit download)

Here are the relevant blog posts:

Visual Studio Starter Kit for Facebook application development

VS.NET starter kit for Nikhil Kothari’s Facebook.NET

Enjoy!
FacebookDel.icio.usDigg It!

Microsoft's ASP.NET MVC framework will be great for Automated UI testing

December 31 2007 6:12AM

I’ve written automated UI tests using Selenuim running against a large ASP.NET Web 2.0 ERP application with great success. However, IMO the single biggest productivity killer for writing such tests is ASP.NET WebForms ID name mangling where ID’s are changed from something like "lblSysMText" at design time to "ctl00_cphContents_dlMessages_ctl01_lblSysMText" at runtime. Fortunately, Selenuim supports the use of XPATH expressions so searching for the above tag can be done using the following:

//span[contains(@id, "lblSysMText")]

Name mangling is a huge problem and thwarts all sorts of automated test tools whether you’re using AutomatedQA's TestComplete or a something like Selenuim. Whenever you have a situation where a simple containership change like moving a control into a DIV can break an automated test you’ve got a problem. These sorts of changes occur all the time on WebForms which are actively being developed meaning unless your tests are written using a partial match logic, like what I’ve illustrated above, you’ll be faced with lots of bogus failures which not only kill productivity but undermine your test automation efforts as the tests will be viewed as fragile and a waste of time.

MVC to the Rescue

Scott Guthrie wrote:

This model view controller (MVC) framework for ASP.NET provides a structured model that enables a clear separation of concerns within web applications, and makes it easier to unit test your code and support a TDD workflow. It also helps provide more control over the URLs you publish in your applications, and more control over the HTML that is emitted from them.

With the MVC framework name mangling will be a thing of the past. I believe not only will the MVC framework make unit testing easier it will be a major win for automated UI testing for ASP.NET apps. You’ll no longer have to jump through hoops to figure out the ID of a given tag on the page.

Last but not least, with MVC style development you’ll finally be able to use ID’s like #lblSysMText in your CSS again.

FacebookDel.icio.usDigg It!

Microsoft's MVC framework means you'll need to rethink your WebForm world

December 20 2007 8:10PM
With the advent of Microsoft’s new MVC framework for ASP.NET I think there will be a fairly significant impact on developers who have come to rely heavily on WebForms and related controls. I believe the new framework will require a significant "rethink" of how applications and controls are developed. If you watch Scott Hanselman’s video you’ll see he uses Rob Conery’s Mvc.ToolKit to flesh out the UI and notice that it doesn’t use the designer nor web controls at all.

The MVC framework is clearly going to change how the VS.NET web form designer will be used and certainly makes it less important. It will be interesting to follow the evolution of the framework and to see how MS updates the designer and code editor to fit this new (as in new to MS) model. It will also be interesting to see how 3rd party control companies like Telerik and Developer Express respond.

While at CodeGear I had frequent discussions with Jim Tierney (who I co-developed Delphi’s ASP.NET designer with) about moving Delphi’s designer away from being a WebForm centric because of the development costs involved and instead focus more on the code editing experience. I think the MVC style of development does just that and I expect Microsoft to come up with a number of improvements to the framework and tooling to better support it. I’ll be curious to watch what this means for Delphi’s ASP.NET support.

One thing I think is particularly interesting is with WebForms out of the way ASP.NET developers will be in a better position to leverage non-Microsoft AJAX frameworks such as Dojo, Prototype etc. etc.

Kudos to Microsoft for following through on this much needed alternative to WebForms!
FacebookDel.icio.usDigg It!