This Blog will be moving!

Posted in Uncategorized on December 16, 2008 by relic411

This blog, along with all of its contents, will be moving to http://www.parallelcoding.com. Come read and enjoy!

Flex Security Error Accessing URL or Channel.Security.Error

Posted in Flex with tags , , on August 11, 2008 by relic411

I had this wonderful error in a Flex Application that I couldn’t figure out.  Every time the app attempted to access the Web Service it returned the error “Security Error Accessing URL”. Well, thanks to this helpful site – http://talsma.tv/post.cfm/flash-9-0-124-and-webservice-over-https-channel-security-error – my problems have been solved.

Apparently there is a security issue with Flash 9.0.124 that requires the following line to be added to the CrossDomain.xml file:

<allow-http-request-headers-from domain=”*” headers=”SOAPAction”/>

Learn to Read and Write

Posted in Work with tags on July 2, 2008 by relic411

There seems to be a shortage of simple skills in the workplace these days. I think I struggle the most when I encounter folks who cannot communicate. And when I say cannot communicate, I mean that they lack the basic skills to communicate ideas clearly and completely through either speech or writing.

My most annoyed moments typically occur after receiving and email from a co-worker that suffers from 1 or more of 3 issues.

  1. I’ve been asked to do something, but the email makes no sense
  2. I’ve been asked a question and when I respond I’m told that they already knew the answer and they’ll go to someone else for help
  3. I reply to an email and no one actually reads it. They somehow guess what I’ve written and assume things that I never intended or communicated.

So serously, take the time to write emails and documentation that are clear  and also take the time to read emails from co-workers. You may actually learn something. And you may actually not annoy the rest of us all of the time.

Content-Disposition attachment vs inline

Posted in .NET, ASP on May 30, 2008 by relic411

Today I ran into an interesting issue. We have some legacy code in .NET 1.1 that exports an HTML table to Microsoft Excel. This export occurs by simply rendering the table via Response.Write and setting the header content-disposition to “attachment; filename=FileName.xls”. The original code looked something like this:

  Response.Clear()
  Response.AddHeader("content-disposition", "attachment;filename=SalesByProductReport.xls")
  Response.Charset = "utf-8"
  Response.Cache.SetCacheability(HttpCacheability.NoCache)
  Response.ContentType = "application/vnd.ms-excel"

  Dim stringWrite As IO.StringWriter = New System.IO.StringWriter
  Dim htmlWrite As HtmlTextWriter = New HtmlTextWriter(stringWrite)

  tblTable.RenderControl(htmlWrite)

  Response.Write(stringWrite.ToString())
  Response.Flush()
  Response.End()

The problem that occurred was that any user using Internet Explorer (surprise, surprise!) would get a prompt to download the file but the file would not download! The file worked properly in all other browsers. The solution is to change

Response.AddHeader("content-disposition", "attachment;filename=SalesByProductReport.xls")

to

Response.AddHeader("content-disposition", "inline;filename=SalesByProductReport.xls")

Now, why exactly does this work? I’m not sure, so if you know please tell me.

Ruby Shoes Build Error On Ubuntu

Posted in Ruby, Shoes, Ubuntu on March 19, 2008 by relic411

When I tried to compile Ruby Shoes I got the following error:

CC shoes/app.c
In file included from /usr/include/signal.h:333,
from /usr/include/sys/ucontext.h:23,
from /usr/include/ucontext.h:27,
from /usr/lib/ruby/1.8/i486-linux/node.h:378,
from shoes/app.c:11:
/usr/include/bits/sigcontext.h:28:29: error: asm/sigcontext.h: No such file or directory
make: *** [shoes/app.o] Error 1

The fix is this:

cd /usr/include/
sudo ln -s asm-i386/ asm

ASP .NET Nested Forms (Or why do I get the error ‘Invalid postack or callback argument’)

Posted in .NET, ASP on March 7, 2008 by relic411

I have now come across a few situations where using nested forms in ASP .NET causes problems. The typical error produced in this case is a ‘Invalid postback or callback argument’ error. This occurs because ASP .NET allows the rendering of multiple, nested forms but fails to validate the forms when a postback occurs. Thus when ASP .NET recognizes nested forms in a page, it marks the page as not valid (Page.IsValid returns false).

The reason that this error occurs is because multiple, nested forms cannot reside on a single aspx page .

The solution is very simple: The submit button for the user created form must contain the following attribute: onclick=”this.form.submit();”. A recent example I came across is below. The basic form that was developed and placed inside an aspx page as a nested form was as follows (only the beginning and ending of this form is shown. The content is not necessary or relevant):

<form accept-charset=”UTF-8″ action=”http://www.response-o-matic.com/mail.php” method=”post” enctype=”multipart/form-data”>

                <table>

                                <tbody>

                                                .

                                                .

                                                .

                                                .

                                                <tr>

                                                                <td colspan=”2″ align=”center”>

                                                                                <input value=” Submit Form ” type=”submit” />

                                                                </td>

                                                </tr>

                                </tbody>

                </table>

</form>

The following code demonstrates the proper way of entering this form so that nested forms will work. Please note that I reiterated all of the attributes (action, method, enctype, etc…) of the form in the JavaScript call.

<form accept-charset=”UTF-8″ action=”http://www.response-o-matic.com/mail.php” method=”post” enctype=”multipart/form-data”>

                <table>

                                <tbody>

                                                .

                                                .

                                                .

                                                .

                                                <tr>

                                                                <td colspan=”2″ align=”center”>

                                                                                <input onclick=”this.form.action=’http://www.response-o-matic.com/mail.php’; this.form.method=’post’;this.form.enctype=’multipart/form-data’;this.form.submit();” value=” Submit Form ” type=”submit” />

                                                                </td>

                                                </tr>

                                </tbody>

                </table>

</form>

SEO 301 Redirects for ASP .NET 1.1

Posted in Uncategorized on February 26, 2008 by relic411

I recently worked on a project where any URL following the form of http://www.mydomain.com/subDomain/Default.aspx needed to 301 redirect to http://www.mydomain.com/subDomain/. Basically this calls for stripping the ‘Default.aspx’ off of any request that has it. The project was to be completed using Visual Basic .NET 1.1.

The solution is  is to add a few lines of code in the Global.asax.vb file inside of the  Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) function. The final product looks like this:

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Dim oPath As String = Request.CurrentExecutionFilePath.ToLower
If Not oPath.EndsWith(“default.aspx”) Then Return

Response.Status = “301 Moved Permanently”
Response.AddHeader(“Location”, “http://www.myDomain.com” + oPath.Substring(0, oPath.IndexOf(“default.aspx”)))

End Sub

Debugging .NET 1.1 With Visual Studio 2003 on Windows XP x64

Posted in Uncategorized on January 24, 2008 by relic411

In order to debug .NET 1.1 properly, it is necessary to uninstall the .NET 2.0 framework when you want to debug. The command to uninstall is:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -u

The command to reinstall when your are done is:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

Selecting a specific number of rows in TSQL

Posted in Uncategorized on December 25, 2007 by relic411

The other day I had the need to select an exact number of rows in a TSQL stored procedure. The circumstances constrained me in multiple ways and I just so happened to come across this little gem of a trick for selecting a set number of rows without using TOP.

All one must do is use the following assigment:

SET @@ROWCOUNT = # of Rows To Select

Then perform the select statement and your in business!

Insert Multiple TSQL Rows

Posted in SQL, TSQL on December 4, 2007 by relic411

The only easy way to insert multiple records in TSQL (and it’s quick!):

INSERT INTO TableName(Columns…)
SELECT Val1, Val2…
UNION ALL
SELECT Val1, Val2…

etc.