Add new website IIS 7 (Vista)
Hello all,
For all of us programmers or web developers working with websites, you know the need to open more then one website (by default) on your development machine.
Sometime you need all a website to stand on its own and not be a sub directory or a virtual directory (like: http://localhost/your_webiste).
Why, well let’s say your using URL rewriting, then you need to use parent path’s like so:
1: <img src="/Assets/Images/Avi.png" alt="" />
if you try to do this while using a VD you will get errors and your images won’t be displayed, you have to use a standalone website for this.
So, let me tell you how to do it with IIS 7 (I’m working with vista, it’s the same for IIS 7 on any other machine).
For all of you guys with XP out there, you cannot do this, so please other upgrade to vista or windows 7 (:-))
I have my own method of how to do this, that make me remember the web address easily.
It goes like this: if I’m working on my website (http://www.kensodev.com) the local version of it will be (http://local.kensodev.com –> link not working).
ok ok I’m getting there
first, open IIS manager on vista (Start—>Administrative Tools—>IIS Manager)
On the left you will see the “sites” folder, right click on it and select “add website”, you will get this dialog
Fill the text boxes just as I did, give it your own names of course and select the local folder where the files are located.
This is just about it for IIS, don’t try to navigate to the website yet, you will get an error.
Next step, please open up notepad (with admin privileges), hit file—>Open (select *.*) and navigate to the folder C:\Windows\System32\drivers\etc
You will see these files
Click the “hosts” file and open it, If you didn’t define any website you will only see “localhost”
Now, we will add a record at the end of this file.
type 127.0.0.1 and hit the TAB button on your keyboard, then type the name that you gave your website. in this case “local.kensodev.com” no need to type http:// or www.
That’s it.
Now, lets open up a browser an navigate to the website
Just to check that the browser isn’t routed to a remote website lets ping to it using the command line.
And that’s the end, you have another website on your IIS, and you can browse to it.
Solo standalone mp3 player to embed in a page
Client’s request:
I want an mp3 player on my website (html), a kind of player which the user can’t pause or stop the song, also I want it to work in all browsers with no problem.
After explaining to him this is not very common and urged him to think it over, he insisted and I had to do what he asked me to.
Because of the cross-browser need, I had to use flash/Flex for this job, but I also wanted to make this as reusable as possible for other project or for distribution as a component which I think a lot will want to use.
So, the plan was a very small player 100x20 (px), white background to blend in with the website.
I didn’t want to hard code the mp3 into the file, because this client is using a CMS application and he wanted to replace the file occasionally.
Opened up flex and started writing some code.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
width="100"
height="20"
creationComplete="init()"
color="#FFFFFF"
backgroundColor="#FFFFFF" backgroundAlpha="0.0">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.messaging.Channel;
private function init():void{
var flashVars:Object = Application.application.parameters;
var mp3FileName:String = flashVars.mp3FileName;
if(mp3FileName!="")
{
playMp3File(mp3FileName);
}
}
private function playMp3File(mp3:String):void{
var snd:Sound = new Sound(new URLRequest(mp3));
var channel:SoundChannel = snd.play();
}
]]>
</mx:Script>
</mx:Application>
As you can see, the entire application is about 29 lines of code.
I’ll explain it:
1. I declared an object that excepts the parameters passed into the FlashObject in the flashVars tag.
2. Checked if the param passed in is not empty and filled a Sound class with this mp3 and whallah –> Start playing.
this is what the HTML embedding of this SWF inside the HTML looks like:
WriteFlashObj('/SoloPlayer.swf', '100px', '20px', true, 'mp3FileName={pageFileName}', 'SoloPlayer');
That’s it.
It works like a charm.
If you want the source code or the final SWF file, please contact me through the contact page of this website, I will email it to you with no problem.
Control caching of your RIA applications
For all of us working with RIA applications (Flex/Flash) we know the hell of having to worry about a user cache.
There's actually a chance that a user won't see the latest version of your application, The chances are actually quite high for that to happen.
Well, I have my own two methods that I use to control this.
1st way
The first way to control this is by the use of a parameter attached to the file name.
Lets say your file name is kenso.swf (original name I must say
). If you try embedding it into the HTML you will found out it is being cached, If you update the file on the server, you won’t see the changes.
The solution for this is simply add a parameter to the file like so: kenso.swf?buildDate=29Jan2009, this will cache as a file, if you change the buildDate param you will see that the file is being pulled again from the server
2nd way
This method is what I call overkill, but I did found myself using it a couple of times in the past.
I won’t get into code (unless you ask me to…) but the Idea is this. There’s a service managing the builds of the application.
Each build of the application has an ID embedded inside the code like so:
1: var versionLabel:String = "29Jan2009_01";
OK, so now we have the version label in the application.
All we have to do is create a service, set the final version expected there say
1: string finalVersion = "30Jan2009_09";
if the version passed into the service is not the latest, simply tell that to your user.
This process can be with or without a database, can be with ExternalInterface and the use of JavaScript, it can really be whatever you want.
I seriously recommend using the 1st way to do this unless you really want to make sure that the version your user is seeing is the latest.