Archive for July, 2012

Asp.net site creating new IP address with Windows Azure

July 25th, 2012

If you have a windows azure project that launches a asp.net site and you are running on IIS Express and for some reason it is incrementing  the IP address up another number, I have the solution for you.  According to Microsoft here is how they assign IP addresses:

“Web role deployments are allocated different increasing IP addresses, starting with get 127.0.0.1, while trying to maintain the port specified in the service definition file. If the service definition file defines two web role deployments and specifies that they use port 8081, the compute emulator would attempt to assign 127.0.0.1:8081 and 127.0.0.2:8081 as the endpoints.

If the port specified in the service definition is in use, then compute emulator tries to allocate an alternate port by monotonically increasing the given port number until one is available. In case of port ranges, the compute emulator tries to allocate a range within which there’s at least one port available.

For example, if port 80 is specified in service definition and is in use by another process, but port 81 is free, the web role deployment is allocated 127.0.0.1:81. The compute emulator will issue a warning that the port in use and unavailable to be allocated as defined in the service definition. The warning appears on the console through CSRUN.exe tool, and in the “Output” window” (“View”->”Output”) for Visual Studio users.”

Microsoft seems to be saying that the emulator handles this for you, mine seemed to not, so all I had to do was stop and start the windows azure emulators and all was good.

SEHException (0x80004005): External component has thrown an exception.

July 20th, 2012

If you get this error with your Azure Cloud project, try this simple fix:  Right click on your cloud project and then choose properties and then choose the Web tab and then if you have it set to “Use IIS Web Server”, switch that to “Use IIS Express” and that could possibly fix this issue for you, it worked for me.

Need an easy and clean way to export your asp.net data to Excel?

July 18th, 2012

If you are doing any research on how to get data contained in asp.net pages out to excel, the first path you may take, like i did was to set the Response, something like this:

Response.ContentType = “application/vnd.ms-excel”;
Response.AddHeader(“content-disposition”,”attachment; filename=BizImportReport.xls”);

Well, this was producing for me an excel file with all of the response in it which included the entire webpage, and no matter how many different ways I tried to get the data into some kind of form that would export well, it never worked, until I came across a little library that does exactly what I want in a couple lines of code, so it looks something like this:

var objExport = new Export(“Web”);
if (DS.Tables[0].Rows.Count > 0)
objExport.ExportDetails(DS.Tables[0], Export.ExportFormat.Excel, “yourexcelfile.xls”);

Here is the link to this library, enjoy  Excel Export Library

 

Google Chrome caches “Like a Boss”

July 18th, 2012

If you do much web development at some point with google chrome you will notice that it is notorious for caching your web pages, which is very frustrating to a web developer when you want to see your changes.  I came across some settings that you can stick in the startup link that will set chrome to never use any cache.

–disk-cache-dir
and
–disk-cache-size

are the parameters…

Simply close Chrome, right-click your Chrome shortcut, click Properties, and then in the field labeled “Target:”, make it look something like this:

“…chrome.exe” –disk-cache-dir=”CACHE_DIR” –disk-cache-size=N

Where ‘CACHE_DIR’ is the new cache location, and ‘N’ is the cache size limit, in bytes.

Here is what mine looks like:  C:\Users\eddie\AppData\Local\Google\Chrome\Application\chrome.exe –disk-cache-dir=”C:\temp” –disk-cache-size=0

 

Bitten by the ASP.net bug (again)

July 16th, 2012

Just wanted to put this out there in case you run into this yourself when you are setting up asp.net or IIS on your system to make or create websites.  If you get this error: “Failure Changing IIS ApplicationHost.config: IIS7Register failed with HRESULT 800700b7: ‘Cannot create a file when that file already exists. ” and you just don’t know what do to, go and check the applicationHost.config  file located in \windows\system32\inetsrv\config folder and change these lines:

<add path=”%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll” allowed=”true” groupId=”ASP.NET v4.0.30319 (32-bit)” description=”ASP.NET v4.0.30319 (32-bit)” />
<add path=”%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll” allowed=”true” groupId=”ASP.NET v4.0.30319 (32-bit)” description=”ASP.NET v4.0.30319 (32-bit)” />

Change the %windir% to your local C:\Windows path and save that and re-run your install of asp.net and all should go as expected.  You can re-install it using this command: C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -i

Hope this helps.

Google Packaged Apps, a very interesting adventure.

July 12th, 2012

I recently stumbled across Google Packaged Apps, something that is in beta testing right now from Google and what could be the future of applications as we know it.  What makes this new technology so interesting to me is that the apps are written completely in javascript and HTML, which runs anywhere.  The biggest drawback that I see thus far is that you are required to run things out of the Chrome browser, which is expected I guess coming from Google, but the idea that you can run an app in its own native window and act and feel like a native app is very interesting.  You can learn more here.

One little piece of advice before you try to run any of the samples, you need to download the latest (experimental) version of the chrome browser called Canary, I tried running the samples inside the current version of chrome and they ran but they won’t run outside of the browser the way they are intended to, the Google guys that wrote the documentation left that little part out, or at least I didn’t see it.

Windows Azure is still in bad need of QA

July 12th, 2012

A friend of mine recently tried to submit a test app through the Windows Azure Hosted Service and got this handy error:

I don’t know about you but telling me to just “Reload the app” probably isn’t going to fix my problems.  I still for the life of me can’t understand why submitting applications to Windows Azure can’t be as simple as committing your code to SVN or Git, I guess they didn’t want to build the app on their side.  I like the way that AppHarbor handles things, I really think it should be that simple and things like authentication should be something we as developers shouldn’t have to think about, isn’t that what “Cloud” computing is all about?

iTunes not grouping albums correctly

July 10th, 2012

Recently I was putting some music on my iPhone 4 and I noticed that it wasn’t grouping the songs in the same album correctly. Apparently iTunes groups the music based on the album name and the artists’ name when you look at it in the iTunes player on the phone. The first thing I tried was renaming it in iTunes which I thought would work after you edit it and it resyncs it back to the phone but that did nothing for me, I also followed these instructions on this site: Why aren’t songs with the same album art grouped together? and this did nothing as well. I finally found a solution, I removed the album from iTunes and then edited it using Windows properties on each song. The main problem with these songs were that they had multiple artists on each track and iTunes will not like it if those are in the descriptions. So you simply find the tracks on your computer, right click each one and go to Properties and go to Details. Make sure you just have the same artist in the “Contributing Artists” box and also the same “Album” in there, apply that to each one of the tracks and then re-import that back into iTunes and your music should show up correctly, I hope this helps anybody with this issue.

Adobe disappoints me a bit..

July 6th, 2012

I have been rolling along with my little PDF fillable form and its working great, I got it working on the acrobat reader on Windows and it even works inside Internet Explorer but I noticing it doesn’t work a whole lot of other places, particularly in the mobile world, which is where I forsee my users really want this functionality to end up.

When I open the PDF in safari or chrome, it will let me fill out the form but the submit button does nothing, which surprised me. It turns out each one of those browsers have their own way of handling the pdf form submissions. Here is my findings so far:

IE – Works
Chrome – No Worky
Firefox – Works
Safari – Could not even get it to load, not sure what is going on there

Then I started testing it over on my Kindle and IPhone and iPad, it pulls up on each one of those but again the submit button does nothing, this is very frustrating. Then I found this link and learned that Adobe doesn’t support it yet, so I am waiting on an update.

Adobe Sucks

My solution to filling Adobe Acrobat forms using shared hosting

July 4th, 2012

In my earlier post I discussed how you can fill in pdf forms via FDF files and send that over to a third party tool like Pdftk. That is all fine and good if you are the admin of your server or you are paying for a private server, but if you are like me and have shared hosting, which I am finding most out there do, you have very limited options, but you do have some options and I am going to show you a little example of what I have done to get it accomplished.

I have attached my snippet of code that will process the HTML form data being sent to your php script as described in my article before.

<?php
require_once('fpdf.php');
require_once('fpdi.php');

//use this if you want to see the posted data
echo'<pre>POST '; print_r($_POST);echo '</pre>';

// initiate FPDI
$pdf = new FPDI();
// add a page
$pdf->AddPage();
// set the sourcefile
$pdf->setSourceFile('test.pdf');
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 0,0 with a width of 200 mm
$pdf->useTemplate($tplIdx, 0 ,0, 200);

//setting font size and color
$pdf->SetFont('Arial');
$pdf->SetFontSize(8);
$pdf->SetTextColor(0,0,0);

//check to see if data is being posted and continue
if(isset($_POST) && is_array($_POST) && count($_POST)){
    
	//fill in First Name 
    	$pdf->SetXY(4, 26);
    	$pdf->Write(0, $_POST['FirstName']);

}else{
    echo 'You did not submit a form.';
	exit;
}

//send the generated pdf to the screen
$pdf->Output('newpdf.pdf', 'D');

?>




Notice that a couple of php files are being referenced at the top, you will need to download the FPDF library found here: FPDF Library and the FPDI library found here: FPDI You will probably need to download both files there to get the correct files. FPDF is only needed because FPDI depends on it.

There is one giant piece of suck to this solution tho, and I can’t find the solution I really want either. The big suck with this is that you are basically positioning the data on top of the pdf via X,Y coordinates, so if you notice around the FirstName spot you see where I am putting it (4,26), so that is 4 over and 26 down on the form. Until I can find a better solution, this is all I got. I would love to find a php library out there that can bind the POST data to the form fields but it doesn’t seem to exist in pure PHP.