Powered by discountASP.NET
referal ID: sdtref
Why recommend discountASP.NET?

Archives
Steve Trefethen Steve's RSS Feed Subscribe or via email
What's this?
Contact me Send mail to the author(s)
About Me
View my LinkedIn profile

Add to Google
Subscribe with Bloglines
MCP Microsoft Certified Professional

Falafel Software
Online or OnSite TestComplete Training
Blogroll
Recent Comments
My Online Tools
Stats
Total Posts: 472
This Year: 77
This Month: 2
This Week: 1
Comments: 1660
Tags
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.
My most popular blog posts (Q1 2008)
# Wednesday, May 28, 2008

Invalid Parameter Error using Facebook Developer Toolkit 1.6

Posted @ 11:49PM

Categories: ASP.NET | Facebook

Tags:  | 

[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!

# Monday, April 21, 2008

URL rewriting in ASP.NET and web.config settings

Posted @ 9:27AM

Categories: ASP.NET | Blogging | Open Source

Tags:  |  | 

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?
# Monday, January 14, 2008

Facebook Starter Kits for VS.NET updated

Posted @ 11:41PM

Categories: ASP.NET | Development | Facebook

Tags:  |  | 

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!
# Sunday, December 30, 2007

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

Posted @ 10:12PM

Categories: ASP.NET | Automation | Testing

Tags:  |  | 

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.

# Thursday, December 20, 2007

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

Posted @ 12:10PM

Categories: ASP.NET | Development

Tags:  | 

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!