April 10, 2008
@ 11:57 AM

I have recently had to do some script debugging, both client and server side and found some good resources on the topic I thought I would pass along. This is one of those things I have do remind myself of how to do from time to time. I typically use Firefox to debug Javascript, but there are times I have to do it with IE.

So below for my own reference as well as hopefully some one else's, are some useful links for debugging Javascript in IE.

Microsoft's Script Debugger can be downloaded from here.

Directions on using it are here.

Monica Rosculet wrote a great article about debugging script with Visual Studio here.

The source of most of this information came from an IEBlog entry that can be found here.

Hope this saves someone else some research time!

Cheers,

Robert Porter


 
Categories: ASP.NET | Browser | Javascript | Programming | Visual Studio


My first project at Ironworks also involves my first experience with Commerce Server from Microsoft. I had not previously worked with Commerce Server so it has been a bit of a learning curve.

I expect to blog about my experiences with this product as I reach a point where I have something significant to say about it. For now I am very much in learning mode.

The other technology areas this project involves are ASP.NET, Plumtree Portal, Javascript, and some BizTalk integration. With the exception of Plumtree I am familiar with the remaining technologies. May or may not post about Plumtree, as I have to say I am less than impressed. I think Sharepoint does a better job than what I have seen of Plumtree but will reserver final judgment for later.

Cheers,

Robert Porter


 
Categories: .NET | ASP.NET | Javascript | Programming | Commerce Server | C#


February 12, 2008
@ 10:58 AM

 

I have stumbled on, been emailed about, or otherwise notified of several interesting new resources of interest primarily for Microsoft Developers. So I thought I would share them here.

MSDN Code Gallery

The newest addition to the ever growing collection of MSDN resources is the MSDN Code Gallery. The code gallery contains code of course, along with video tutorials, sample applications and lots of other resources. It supports user uploads as well, so count on the gallery growing over time. From a rather quick look see on my part it does seem to contain some worthwhile resources.

MSDN Reader

If you have used or seen the New York Times reader then you will instantly recognize the new MSDN Reader. It is a WPF based application that allows you to read MSDN Magazine online. It appears that you do not have to have a subscription to use this, however I am unsure if that will remain true. But it is certainly worth a look.

MSDN Windows Vista Developer Center

This site has recently been overhauled significantly and (to me) seems easier to navigate and find information on. The Windows Vista Developer Center is full of resources related to developing applications that run on Vista and take advantage of features available in Vista as well as the recently launched Windows Server 2008. Of interest on this site was the announcement that SP1 for Vista has been released to manufacturing. Most folks don't consider an operating system or application as truly viable until at least the first service pack. So if you have been waiting for SP1 to look at Vista, your wait is over.

Hopefully one or more of these resources will prove useful to you!

Cheers,

Robert Porter


 
Categories: .NET | Ajax | ASP.NET | Programming | Reviews | Tools and Toys | VB.NET | Visual Studio


Microsoft has released a number of exciting new tools and technologies that certainly bear some watching! These are preview releases so the usual caveats apply about installing these on a production system.

The "home" page for Microsoft's Data Platform is here and it contains the most up to date information about the various shiny new pieces.

The main bits are ADO.NET Entity Framework Beta 3, ADO.NET Data Services CTP1, and ADO.NET Entity Framework Tools CTP2.

So what exactly is the Entity Framework? It's a toolset and framework that enables a developer to visually design and model data driven applications, both forms based and web based.

Collectively these technologies are part of the ASP.NET 3.5 Extensions which are in preview mode at the moment. Combined these technologies allow a developer to expose data from their applications in well known formats, some of which are not Microsoft specific such as JSON and REST and also in standards based formats such as XML.

There are a number of QuickStarts that the ASP.NET team has made available. Also as part of this release the ASP.NET MVC framework is available.

Go check it out!

 


 
Categories: .NET | ADO.NET | Ajax | ASP.NET | Programming | SQL | Visual Studio


December 7, 2007
@ 10:01 AM

Microsoft has released a Live Lab's (Microsoft Research and Live Services) preview technology package called Volta.

Volta is a framework that allows a developer to potentially build a multi tier application initially as an client application, and then use a technique called "declarative tier-splitting" to identify which pieces of the application run on a server and which pieces run on the client.

This is accomplished by using and XML like declarative markup within the code. With this approach a developer can focus on getting the application designed and functional and then let Volta split the tiers and create the communications "glue" that lets the applications tiers work together.

How this is accomplished is rather interesting, Microsoft decided to go with an MSIL based approach, mostly accomplished in the post compilation area. MSIL code is rewritten to run in Javascript for the client, and ASP.NET for the server side, typically as a web service.

Since Volta works it's magic at the MSIL level, any CLR targeted language is supported, C#, VB.NET, IronPython and others. Visual Studio 2008 is required at this stage, 2005 is not supported and it is unclear if it will ever be.

So show me some code already!

The code shown below is from the Volta Recipe's page. It shows the [RunAtOrigin] custom attribute in use.

namespace VEMashup.Weather
{
    [RunAtOrigin]
    public class WeatherSvcProxy
    {
        public string GetJsonWeatherInfoFor(double lat, double lng)
        {
            var baseUri = @"http://ws.geonames.org/weatherIcaoJSON";
            var uri = baseUri + "?lat=" + lat.ToString() + "&lng=" + lng.ToString();
            var xhr = new Microsoft.LiveLabs.Volta.Xml.XMLHttpRequest();
            xhr.Open("GET", uri);
            xhr.Send();
            if (xhr.Status == 200)
                return xhr.ResponseText;
            else
                return null;
        }  
    }
}

 

This is an example of "tier splitting" via markup. This tells the Volta framework that this code is destined to run on the server. Code not marked will continue to run on the client. This means that as a developer you can postpone deciding how and where to partition your application until the last minute.

The agile developer in me seriously enjoys this particular aspect! Volta technology is seriously early in the life cycle however, so bear in mind that this will change before it gets released.

There is a handy list of known issues you should review before you start playing with the framework.

You could think of Volta as architecture refactoring on steroids. As shown below Microsoft has designed it explicitly with that in mind. (Image from Volta Web Site.)

image001

Bear in mind that you are not limited to 2 tiers, you can retarget portions of your application to as many tiers as you want!

All in all I think this bears some watching!

Cheers,

Robert Porter


 
Categories: .NET | Agile | ASP.NET | Javascript | Programming | Reviews | TDD | Tools and Toys | VB.NET | Visual Studio | XML


Scott Hanselman and ScottGu did a recent public presentation on the new Model View Controller Framework implementation that Microsoft is developing.

Scott has a post with some links to videos of the presentations as well as some great background information.

Roy Osherove has a post about this as well, it can be found here. While MVC has been around for quite awhile now, this is the first time Microsoft has officially supported the concept as opposed to their own Frameworks. I think it is worth reading up on, especially if you are a web developer.

Cheers,

Robert Porter


 
Categories: .NET | ASP.NET | Programming | Visual Studio


September 25, 2007
@ 12:10 PM

Matt Blodgett posted an very timely (for me) on an issue with debugging web applications on Windows Vista. Read the full article on his site, but if you are having issues where VS2005 mysteriously leaves debug mode while you are sitting on a line of code this is your answer!

Cheers,

Robert Porter


 
Categories: .NET | ASP.NET | Programming | Visual Studio


September 21, 2007
@ 12:21 PM

A number of blogs incorporate scrolling blocks of text in their blog posts. This helps keep things organized and neat in the post.

The last time I needed to do this I used JavaScript, but since a lot of users turn scripting off for security reasons, I looked around and found a way to do it with good old CSS.

<div style="overflow:auto; height: 200px; width: 300px;>
<p>Some text to scroll around with.</p>
</div>

See it in action below:

 

Public Function GetClosedCount() As Long

 
        Dim oInboxAgenda As WFXTENDERLib.WfxAgenda
 
        Try
            ' Navigate to the Inbox for the Initial Routing Workflow user
            oInboxAgenda = oWFXConnection.Agenda(WORKBOX_TYPE_CLOSED)
            'Clear previous filters
            oInboxAgenda.SetFilter("", "", "")
            oInboxAgenda.SetFilter("Business Process", "=", "Initial Routing Workflow")
            'Refresh data so filter is applied
            oInboxAgenda.Refresh()
 
            Return oInboxAgenda.Count
        Catch eX As System.Exception
            MsgBox(eX.ToString)
        Finally
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oInboxAgenda)
            oInboxAgenda = Nothing
        End Try
 
    End Function

 

So in a nutshell, a simple DIV and some CSS goes a long way. An added benefit is that this simple tag is supported on almost every browser.

I am still trying to figure out other ways to do this, I would prefer not having to hack the html view of my posts each time. But this works for now.

Cheers,

Robert Porter


 
Categories: ASP.NET | Browser | CSS | dasBlog


I recently had an issue with an application that uses the ASP.NET 2.0 Membership API and the standard Login control.

Basically, seemingly for no reason I could determine, all Login attempts failed with ubiquitous error “Your login attempt was unsuccessful.”.

I checked all the membership provider settings in web.config, checked the database, all the standard things. Everything was fine. After a lot of digging, even rebuilding from scratch the database tables involved, I still could not resolve the issue.

The “Lost Password’ functionality worked, it happily asked you for the answer to your secret question and e-mailed the retrieved password as it should. This told me that the infrastructure and providers were all functioning.

I added the following code to the LoginError handler in an attempt to diagnose what was happening:

    5 Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoginError

    6         'See if this user exists in the database

    7         Dim userInfo As MembershipUser = Membership.GetUser(Login1.UserName)

    8 

    9         If userInfo Is Nothing Then

   10             'The user entered an invalid username...

   11             LoginErrorDetails.Text = "There is no user in the database with the username " & Login1.UserName

   12         Else

   13             'See if the user is locked out or not approved

   14             If Not userInfo.IsApproved Then

   15                 LoginErrorDetails.Text = "Your account has not yet been approved by the site's administrators. Please try again later..."

   16             ElseIf userInfo.IsLockedOut Then

   17                 LoginErrorDetails.Text = "Your account has been locked out because of a maximum number of incorrect login attempts. You will NOT be able to login until you contact a site administrator and have your account unlocked."

   18             Else

   19                 'The password was incorrect (don't show anything, the Login control already describes the problem)

   20                 LoginErrorDetails.Text = String.Empty

   21             End If

   22         End If

   23 

   24     End Sub

 

The code was falling into the last else, which would indicate that the password was incorrect. Which I was very sure was not the case! I created a simple two page application from scratch, hooked it up to the same database and dropped a login control on it. And it worked! So why was my application not working?

 

Well, I stumbled on this thread on the ASP.NET Forums, the reply posted by “mandert” turned out to be the answer. There was an “empty” Login1_Authenticate event handler in the code. Apparently this prevents the internal authenticate event for the login control from firing! If you ask me this is a bug, but then again maybe not. Anyway, check your code for empty events associated with the authentication controls. Delete them, it will solve a number of issues and save you lots of hair!

 

Cheers,

 

Robert Porter


 
Categories: .NET | ASP.NET | Programming | Visual Studio


There are literally dozens of articles on how to retrieve images from a database and display them in a web page.  The vast majority use one of two variations.

Variation 1

Retrieve the image data, save it to a temporary file and then use the file as the image controls ImageURL or src.

Variation 2

Use an .aspx page with its content type set to an image/xyz type and retrieve the image within the ‘loader’ page and use that page as the image controls ImageURL or src.

I can’t use Variation 1 because I don’t want to create temporary files for a variety or reasons. Variation 2 works for individual images but I need to be able to quickly pull back up to 12 images and I experienced problems using this method within a loop from the calling page.

So here comes Variation 3. I am still not 100% satisfied by this but it works. As an aside since I can retrieve the image as a byte array directly from the database I would love to be able to do something like:

PageLoad Event

Go get image from DB and return it as either a Byte Array or a memorystream

Image1.ImageURL.LoadFromStream(ms)

Alas even though I wish it to be true it does not appear to be possible. However in the Wrox Book “ASP.NET 2.0 MVP Hacks and Tips” I stumbled on what turned out to be my solution in chapter 17 the part titled “Compositing Images with an HttpHandler” which was written by Scott Hanselman

So my solution was a variation on Variation 2, I created a HttpHandler class that in essence does the same thing, it retrieves the image data and then writes the image directly to the output stream and so I can now call my handler and pass in some parameters like this:

Using the html img tag:

<img src="GetImages.ashx?RecID=90&Size=Small">

Or using the server side model:

Image1.ImageUrl = "~/GetImages.ashx?RecID=90&Size=Model"

This method works like a champ even in a loop, and seems to be much faster than the .aspx page method. Not sure why, perhaps an HttpHandler does not have the overhead a full .aspx page does, but it sure works well.

The full code for my solution is below: Note: this was test code, I would NOT recommend using dynamic SQL like I do below in a production application, instead use parameterized sql.

<%@ WebHandler Language="VB" Class="GetImages" %>

    1 Imports System

    2 Imports System.Web

    3 Imports System.IO

    4 Imports System.Drawing

    5 Imports System.Drawing.Imaging

    6 

    7 Public Class GetImages : Implements IHttpHandler

    8 

    9     Public Sub ProcessRequest(ByVal ctx As HttpContext) Implements IHttpHandler.ProcessRequest

   10         'Create the request object and retrieve the QueryString Parameters

   11         Dim req As HttpRequest = ctx.Request

   12         Dim iRecID As Integer = CType(req.QueryString("RecID"), Integer)

   13         Dim sPicSize As String = CType(req.QueryString("Size"), String)

   14         Dim img() As Byte = GetData(iRecID, sPicSize)

   15         ctx.Response.ContentType = "image/gif"

   16 

   17         If (Not (img) Is Nothing) Then

   18             Dim m As MemoryStream = New MemoryStream(img)

   19             Dim image As Image = System.Drawing.Image.FromStream(m)

   20             image.Save(ctx.Response.OutputStream, ImageFormat.Gif)

   21         End If

   22 

   23     End Sub

   24 

   25     Public Function GetData(ByVal iRecID As Integer, ByVal sPicSize As String) As Byte()

   26 

   27         Dim cnn As Data.SqlClient.SqlConnection

   28         Dim cmd As Data.SqlClient.SqlCommand

   29         Dim msTemp As New MemoryStream

   30         Dim strSQL As String

   31 

   32         Select Case sPicSize

   33             Case "Large"

   34                 strSQL = "SELECT LargeImage FROM cyb_Frames WHERE RecID=" & iRecID

   35             Case "Small"

   36                 strSQL = "SELECT Thumbnail FROM cyb_Frames WHERE RecID=" & iRecID

   37             Case "Model"

   38                 strSQL = "SELECT ImageWithModel FROM cyb_Frames WHERE RecID=" & iRecID

   39             Case Else

   40                 strSQL = "SELECT LargeImage FROM cyb_Frames WHERE RecID=" & iRecID

   41         End Select

   42 

   43         Dim connString As String = Web.Configuration.WebConfigurationManager.ConnectionStrings("xyz").ConnectionString

   44         cnn = New Data.SqlClient.SqlConnection(connString)

   45         cmd = New Data.SqlClient.SqlCommand(strSQL, cnn)

   46         cnn.Open()

   47 

   48         Return cmd.ExecuteScalar

   49 

   50     End Function

   51 

   52     Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

   53         Get

   54             Return False

   55         End Get

   56     End Property

   57 

   58 End Class


 
Categories: .NET | ASP.NET | SQL | VB.NET


August 10, 2006
@ 10:34 AM

I am slowly getting up to speed with dasBlog, and I have to say I am impressed… and confused! However the confusion is correctable. It stems mostly from not yet being able to get my development environment up to speed. ( I use VS2005 exclusively and dasBlog was and remains written for and in VS2003 and .NET 1.1 )

There are some posts that help with setting your development environment up for VS2005 such as the one here as well as reading through some of the forums and of course just plain hitting Run and seeing what blows up.

What I am impressed by is the fact that unlike several other open source projects the current developers seem to encourage contributions and patches. I can’t say the same for efforts like an unnamed blog engine I used before, where a submission goes unacknowledged and posts to their forums disappear after a day or two with no explanation.

And from what code I have seen, it looks in way better shape than most, so that is hopeful. Some of the rest of my confusion stems from the fact that dasBlog uses flat files for content storage as opposed to a database. And category lists seem to be driven by use not a stored list.

This makes it sort of difficult for someone using an external tool to blog with. I use BlogJet myself and am very happy with it, however either it or dasBlogs implementation of the Blogger interface do not yet support Categories that it does not obtain from the blog engine. In other words the category must exist already before you can use it in BlogJet. So the solution (Clarification: The solution was provided to be my Scott Hanselman not my own discovery, after I sent an email asking about the issue.) was to create a placeholder post and assign it every category I thought of (and periodically have to edit it to add new ones) just so I can use them in my external tool.

But as I get more familiar with the engine and the code, I should begin to learn the reasoning behind these decisions and be in a better position to comment on them then.

Cheers,

Robert Porter


 
Categories: ASP.NET | dasBlog


August 9, 2006
@ 04:47 PM

Just ran into another interesting gotcha with ASP.NET 2.0, if you are using any form of DotNetNuke don't install it in the root of your website! When I test posted my current project to my own hosting server to work with, I got some very strange behaviour. After a fair amount of digging I stumbled on a post having to do with DNN and other apps having difficulties existing together if DNN was at the root level.

Reinstalled DNN as a vDir and put a redirect page up and everything came back to life!

Cheers,

Bob Porter


 
Categories: .NET | ASP.NET | Atlas | Ajax - Atlas | Ajax


I have recently had occassion to enable an existing web site project for Atlas functionality. It was reasonably straightforward and I wanted to share some of the links I found that helped me along, as well as some of the unique issues I encountered.

Jay Kimble posted an article on CodeBetter.Com that was very helpful.

Scott Guthrie’s whole blog is a fantastic resource for all things Atlas and ASP. (For the longest time I thought his last name was Gu!) In particular take a look at his ASP.NET 2.0 Tips, Tricks, Recipes and Gotchas article.

And of course the home page for the Atlas project here is a great resource.

Now onto the unique issues I encountered, mostly what was happening was that I was getting no where when inserting an Atlas tag into my pages, the infamous “red squiggly line” kept showing up. After a great deal of wailing, gnashing and web searching I realized that I had installed the last 3 CTP releases on top of each other. So I cleaned everything off (literally, I ended up re-paving my laptop!!!) and reinstalled everything from scratch and only the latest and greatest which at the time of this writing is the July CTP release.

Once that was done, and yes I had other issues than just the Atlas stuff, I was gratified to not see red squiggles everywhere in my code!

I hope this helps point someone in the right direction if they end up where I was. Hopefully not quite as drastic a fix as mine however!

Cheers,

Robert Porter


 
Categories: ASP.NET | Atlas


January 2, 2005
@ 12:41 AM

Hmmm