Pages

Advertisement

Sunday, November 1, 2009

Xperia Pureness unboxed, performs for the camera (video)

As you are no doubt well aware, the launch date for the Xperia Pureness is looming. If you've been dying for a closer look, you're in luck: the fashion icons over at MobileBurn have got their hands on one and have been kind enough to make us a short film of the reveal. At first blush, the phone doesn't look any less impressive than it did in the shots and video we've seen before. There doesn't appear to be any hint of a keypad before the thing when shut off, although that obviously changes once it's powered on. As far as that transparent glass display goes, we can tell from here that it's not likely to be visible in direct (or even some indirect) sunlight -- but since you're a jet-setting nightclub habitue' who hasn't been outside in the daylight in four years that probably shouldn't bother you much. The UI is pretty much standard for an SE feature phone, and the battery is not removable. The price? Looks like it will run you a healthy £530 (about $875). Still interested? Peep the video in action after the break.

HDI's laser-driven 3D HDTV hits production, should ship next year

When we first caught wind of HDI's "world's first laser-based 3D HDTV," we were cautiously hopeful that it'd be ready to go (at least as a prototype) at CES 2010. Looks like we may actually get our wish, as the company has today announced that its magical set has reached the manufacturing stage. What's it all mean? It means that the set is being fast-tracked for release in 2010, meaning that you're just months away from having stereoscopic 1,920 x 1,080 content in your living room... provided there's actually any programming to view, that is. Of course, it'll handle the 2D stuff too, and the twin RGP LCoS micro-display imagers in there ought to provide plenty of crisp imagery regardless of the source. We're still not sure if the Woz-approved 100-inch version that's being shown to curious onlookers is the size that'll be pumped out to the mainstream, but we're hoping for at least a few smaller siblings for those of us with last names other than Kennedy, Gates, Buffet and Ellison.

Gallery: HDI's laser-driven 3D HDTV hits production, should ship next year

xpPhone teased with specs and pictures, makes Windows XP young again

Don't panic, we haven't gone back in time. What we're looking at here is the world's first but still-yet-to-be-released phone that runs on Windows XP, and its Chinese maker has just released some juicy specs and interface images to tease us all. The ITG xpPhone will be blessed with the chutzpah-filled AMD "Super Mobile" CPU, coupled with either 512MB or 1GB RAM. Storage options range from 8GB SSD to 120GB HDD (probably 1.8-inch) and everything in between. While the sheet confirms both GSM and CDMA support, ITG's pre-order page -- which looks more like a newsletter sign-up page at the moment -- is still vague on the phone's availability and price. For now we'll just continue to gaze at the interface pictures until something happens.

Gallery: xpPhone teased with specs and pictures, makes Windows XP young again

There're people who talk about Me on the Internet?

 

reputation managementHere’s a complete guide to some of the best tools that will help you track what other people are saying about you, your business or your products on other websites, forums and social media sites.

You can secretly "listen" to conversations happening on the web in almost real-time and can then respond if you think a "negative" comment posted on another site may harm your own reputation or that of your brand.

All the "buzz monitoring" services mentioned in this guide are available for free and they can help you monitor almost every part of the "public" web including blogs, forums, websites, video sites, user comments and even some social networks.

Monitor Your Name or Business on the Internet

1. Google Search – Type your name (or that your business) in the Google search box and use the "Past 24 hours" with "Sort by Date" option to find the most recent web pages, blog posts, forum threads, etc. that are talking about you (see example).

google search

If people tend to misspell your name, you should always use a search phrase that includes both your real name and the misspelled version separated by OR (in caps). 

Since Google doesn’t offer feeds, you should consider adding the results page to your bookmarks folder that you open every morning.

2. Yahoo! Alerts – If you are some sort of a celebrity who’s frequently quoted in the press or if you’re a business looking to track your brand mentions in print media, Yahoo! Alerts can be great option. It will send you an email message as soon as there’s a news story in some publication that mentions you or your brand.

yahoo alerts

3. Google Alerts – Unlike Yahoo! News Alerts that primarily track mainstream media sources, Google Alerts will include stories* from blogs, regular web pages as well as traditional media if you go for the "comprehensive" option. You can even subscribe to Google Alerts in your favorite feed reader.

Google Search vs. Google Alerts – Google Search (mentioned at #1) will find each and every web page that mentions you but Google Alerts will only find web pages that appear in the top twenty results of Google Web search so you are likely to miss some pages if you rely solely on Google Alerts.

[*] See tutorials on how to use Google Alerts and Google News effectively.

4. Facebook Public Search – Facebook has 300+ million members and chances are high that some of them are talking about you or your product in their status updates and wall posts.

facebook public search

Type your name in the Facebook search box (upper right corner) and then use the "Posts by Everyone" option to finds status updates, links and notes written by other Facebook member that mention your name. This will show content from all Facebook members who have enabled their posts to be viewed by people other than friends.

5. Yahoo Pipes (for blogs) – Google Blog Search, Technorati and Bloglines from Ask.com are some popular blog search engines to help you discover blog posts that link to one of your web pages.

yahoo pipes blog search

You can type the address of your website in this Yahoo! Pipe and it will merge results from all the different blog search engines into one feed that you can either subscribe via email or in your feed reader.

6. Twitter Search – In addition to regular search operators, Twitter search also supports location parameter so you can limit search results to a particular geographic region.

For instance, if you are handling PR for a US based company who just launched a new product in India, you can use a query like "Product Name near:India" to find reactions on Twitter only from India and nearby regions (just what your client wants).

7. Digg Search – Do you know that Digg, like Google, also supports the site: search operator. Use this with your site, choose the "newest first" option and you’ll immediately know when people add your stories on Digg.

digg search

They may not hit the front page but will you’ll still know about them – see example.

8. Back Tweets -  Type your web domain name and it will show you all messages on Twitter that include a link to your website (see example). This is just like another useful version of Google’s link: operator but for Twitter (see related services).

9. Back Type – Unlike blog search engines that only index blog posts, Back Type indexes the comments left by other users on blog and other social sites including FriendFeed and Digg.

Type the name of your product or service in the search box, choose "all" (default setting is "relevant") and it will help you find comments /discussion on the Internet that mention you (see example).

10. StepRep – This is another brilliant service for online reputation management. It monitors what people are saying about you (or your products) online and will notify you by email when new results are found.

steprep reputation management

There may be some overlap with Google Alerts but StepRep can routinely discover sites that mention you but have been missed by Google Alerts. You may use your existing Google Account to log into StepRep.

11. Truveo Video – AOL owned Truveo is probably the largest search engine for video that indexes video clips from all possible video sources on the web including YouTube, Flickr, MySpace, and more. And this is precisely the reason why you should prefer Truveo over Google Video Alerts for tracking your brand mentions on video sites.

You can subscribe to Truveo search results in a feed reader.

12. Social Mention – Another excellent service that helps you track your name across different social media sites like Digg, Twitter, StumbleUpon, etc. from a central place. You may get results via RSS or subscribe to once-a-day email alerts for all the keywords that you are monitoring on the web.

13. Webmaster Central - This is one of the best tools to find out other sites that are linking to your web pages (another tool that you may use is Yahoo! Site Explorer).

google webmaster links

Assuming that you’ve already verified your site with Webmaster Central, go to "Your site on the web" -> "Links to your site" and there you’ll see a list of all external pages that link to one of your pages. This table can be huge if you run a popular site but there’s an option to export the complete result-set into Excel for further analysis.

A Visual Guide to Computer Cables and Connectors

Computer cables can be confusing so here’s a quick visual guide that will help you quickly identify almost every cable that came bundled with your computer and other electronic gadgets. You may also refer to this guide for ideas on how to hook different devices using commonly available connectors and converters.

usb cable

1. USB Cables and Connectors

What are USB cables used for – You can use USB cables to connect most new devices to your computer including flash memory sticks, portable media players, internet modems and digital cameras.

Computer accessories like mice, keyboards, webcams, portable hard-drives, microphones, printers, scanners and speakers can also be connected to the computer through USB ports. Additionally, USB cables are also used for charging a variety of gadgets including mobile phones or for transferring data from one computer to another.

usb symbolHow to recognize USB Cables – The standard USB connector, USB-A, is a rectangular connector. The USB-A end is present on every USB cable as it is the end that connects to your computer.

The other end of the USB cable may have different connectors including USB-B (a square connector commonly used with printers, external hard drives, and larger devices) or smaller connectors such as the Mini-USB and Micro-USB that are commonly used with portable devices such as media players and phones.

USB cable converters

Additionally, many other connectors have USB-A connectors at the end that connects to the computer, and a device-specific connector at the other end (e.g. the iPod or a Zune). Then you have USB Male to Female connectors for extending the length of a USB cable.

Many other non-USB cables can also connect to your computer via a USB converter; these cables have the standard USB-A connector on one end while the other end could have connections for other ports such as Ethernet or audio.

2. Audio Cables and Connectors

2.1 – 3.5mm headphone jack

Standard 3.5mm audio jack The most common audio cable is the standard headphone jack, otherwise known as a TSR connector. It is available in several sizes, but the most common ones used with computers are the 3.5 mm or 1/8" mini audio jack.

Most speakers and microphones can connect to the computer with these audio cables. The microphone port on your computer is usually pink while the speaker port, where you insert the stereo audio cable, is colored green. Some computers have additional TSR audio ports colored black, grey, and gold; these are for rear, front, and center/subwoofer output, respectively.

trs connectorA larger variety of the TSR connector, 1/4″ TRS, is commonly used in professional audio recording equipment and it can be connected to a computer using an 1/4" to 1/8" converter (pictured right).

2.2 – Digital Optical Audio

For high-end audio, like when you want to connect the output of a DVD player or a set-top box to a Dolby home theater, you need the TOSLINK (or S/PDIF) connector.

toslink optical cable

These are fiber optic cables and can therefore transmit pure digital audio through light. Some laptops and audio equipment have a mini-TOSLINK jack but you can use a converter to connect it to a standard TOSLINK (Toshiba Link) port.

3. Video Cables

3.1 – VGA

One of the most common video connectors for computer monitors and high-definition TVs is the VGA cable. A standard VGA connector has 15-pins and other than connecting a computer to a monitor, you may also use a VGA cable to connect your laptop to a TV screen or a projector.

VGA cables and converters

Converter cables are lso available to let VGA monitors connect to newer computers that only output HDMI or DVI signals. A smaller variant of VGA, Mini-VGA, is available on some laptops but with the help of a converter, you can connect any standard VGA monitor to a Mini-VGA port of your laptop.

3.2 – DVI Monitor Port

dvi cableIf you have purchased a computer in the recent past, chances are that it uses DVI instead of VGA. The new breed of "thin" laptops use the smaller variants of DVI like the Mini-DVI and Micro-DVI (first seen in MacBook Air).

A DVI cable has 29 pins, though some connectors may have less pins depending on their configuration. DVI’s video signal is compatible with HDMI, so a simple converter can allow a DVI monitor to receive input from an HDMI cable.

Additionally, DVI to VGA converters are also available for connect your new graphics card to old monitor that supports only VGA mode.

s-video cable

3.3 – S-Video

S-Video cables, otherwise known as Separate Video or Super Video cables, carry analog video signals and are commonly used for connecting DVD players, camcorders, older video consoles to the television.

Standard S-Video connectors are round in shape and may have anywhere between 4-9 pins.

4. Audio and Video Cables

4.1 – RCA Connector Cables

RCA connector cables are a bundle of 2-3 cables including Composite Video (colored yellow) and Stereo Audio cables (red for right channel and white or black for the left audio channel).

RCA cables and connectors

Sometimes additional cables may be included, offering additional audio channels and/or component video instead of composite. Component video offers better picture than composite because the video signal is split in different signals while in the case of composite, everything is transferred through a single yellow plug.

Uses of RCA Connectors – The RCA cables are usually used for connecting your DVD player, stereo speakers, digital camera and other audio/video equipment to your TV. You can plug-in an RCA cable to the computer via a video capture card and this will let you transfer video from an old analog camcorder into your computer’s hard drive.

4.2 – HDMI Cables

hdmi cableHDMI is the new standard that provide both audio and video transmission through a single cable. HDMI support a maximum resolution of 4096×2160p (HD is only 1920×1200) with up to 8 channels of digital audio and are used for connecting Blu-Ray players to an HDTV.

Standard HDMI cables can be up to 5 meters long, but higher quality ones can be up to 15 meters long, and the length can be further increased with amplifiers. HDMI is backwards compatible with DVI so you can use a converter to watch video on a DVI device through the HDMI cable though you will have to use another cable for the audio.

4.3 – DisplayPort

DisplayPort - MacBookA combined digital video and audio cable that is more commonly used in computers is DisplayPort and the smaller derivative Mini DisplayPort. Both support resolutions up to 2560 × 1600 × 60 Hz, and additionally support up to 8 channels of digital audio.

Mini DisplayPort connector is currently used in MacBooks but we could them in other computers as well in the near future.

Standard DisplayPort cables can be up to 3 meters long, but at a lower resolution cables can be up to 15 meters long.  DisplayPort connectors are available to connect VGA, DVI video, or HDMI video and audio with a DisplayPort cable or connection.  Additionally, converters are available to convert Mini DisplayPort into standard DisplayPort.

5. Data Cables

firewire ieee 1394 5.1 – Firewire IEEE 1394

Firewire, otherwise known as IEEE 1394, i.LINK, or Lynx, is a faster alternate to USB and is commonly used for connecting digital camcorders and external hard drives to a computer. It is also possible to ad-hoc network computers without a router over FireWire.

Firewire typically has 6 pins in its connector, though a 4 pin variety is common as well.

5.2 – eSATA Cables

esata for hard drives While SATA cables are used internally for connecting the hard drive to the computer’s motherboard, eSATA cables are designed for portable hard drives, and can transfer data faster than USB or FireWire.

However, the eSATA cable cannot transmit power, so unlike USB, you cannot power an external hard drive with eSATA. The eSATA cable is somewhat different from the internal SATA cable; it has more shielding, and sports a larger connector.

6. Networking Related Cables

phone cable rj411

6.1 – Phone RJ11 Cable

The telephone cable, otherwise known as RJ11, is still used around the world for connecting to the Internet through DSL/ADSL modems. A standard phone cable has 4 wires and the connector has four pins.

The connector has a clip at the top to help maintain a tight connection.

ethernet cable rj45

6.2 – Ethernet Cable

Ethernet is the standard for wired networking around the world. The Ethernet cable, otherwise known as RJ45, is based on Cat5 twisted pair cable and is made from 8 individual wires.

The Ethernet connector, likewise, has 8 pins and looks similar to a phone plug, but is actually thicker and wider. It too has a clip to help maintain a tight connection like a phone connector.

Download All Your Documents from Google Docs as a Zip File

While Google Docs is brilliant, the only issue is that you need an active Internet connection to create new Office documents in Google Docs as well as for editing /reading old files that already exist in your Google account.

That’s a problem because, unless you use something like Google Gears, you won’t have access to your Google documents while you are in an airplane or are using an old computer that has Microsoft Office but no Internet connection.

Download Google Documents for Offline Use

Therefore the best option is that you download a copy of all your documents, PDFs, etc. from Google Docs and put them on a local hard-drive or USB stick so that you can at least read them which you are in offline mode.

While there are third-party tools that let you easily download Google Documents to the local drive in one go, the good news is that the batch export feature is now available in Google Docs by default so you don’t have to hunt for external tools to help you do so.

Select Google Documents for Exporting

export google docs

Just open your Google Docs account and select the documents that you want download locally.

Then use the Export option from “More Actions” and within minutes, all your Google documents will be available on the desktop as one large zip file. You may even convert Office files to PDF or HTML format before exporting them out of Google Docs.

Choose the Export Format – PDF, Word, etc.

download google documents

Want Some Fresh Air? Get These Indoor Plants for your Home

While completing my TED profile, I came across a very interesting presentation by environmentalist Kamal Meattle who talks about how you can grow your fresh air at home and office using some commonly available indoor plants.

Best Indoor Plants for “Cleaning” Air

The three indoor plants that Kamal mentioned in his TED talk include:

best indoor plants

1. Areca Palm - You need at least four shoulder-height plants per person in the building and, if you are living in a polluted city, make sure you wipe the Palm leaves every single day for the plant to effectively convert Carbon dioxide into Oxygen.

You should in fact grow two sets of Areca Palm’s -- keep the other set outdoors and rotate that set with the indoor one every 3-4 months.

2. Snake Plant -- Unlike most plants which release Carbon-dioxide at night, Snake Plant (also known as Mother-in-law’s Tongue) does the reverse as it converts CO2 into Oxygen at night so you can safely keep it inside the bedroom.

You need at least 6 to 8 waist height plants per person to improve the indoor air quality to a healthy level.

3. Money Plant -- Other than releasing oxygen in the air, money plant can also eliminate formaldehyde from the air that is commonly released by cigarette smoke and adhesives (used with wood furnishings).

Money Plant is therefore especially useful in office buildings as they generally have lot of wooden furniture.

NASA Study on Indoor Plants

If you have some space in your home or office premises, it probably makes lots of sense to grow these plants because research says that there is a 42% probability of increasing blood oxygen by 1% if one stays inside a building housing these plants for 10 hours.

And Kamal isn’t the only person saying this. Earlier, a study conducted by NASA also suggested that certain houseplants (including Bamboo Palm and Snake Plant) can remove as much as 87% of indoor air pollutants within 24 hours.

Want Some Fresh Air? Get These Indoor Plants for your Home

Review: The Motorola Droid

droid_008

A few days ago we got Motorola’s Droid in the mail. The device is quite awesome. Beyond being offered on Verizon’s network (which consistently squelches AT&T in coverage and speed) the phone is forged from super-solid (and stylish) hardware. Plus it runs freaking Android 2.0 as its OS. From reviewer Priya Ganapati:

The Droid runs Android 2.0 (aka Éclair) as its OS. It feels more refined than the first version of Android on T-Mobile’s G1 and it’s certainly better than the muddled interface on Motorola’s Cliq.

The Droid’s 5-megapixel camera has up to 4x digital zoom. It produces photos that aren’t too noisy and it does well even in low light, thanks to the built-in LED flash.

The most exciting feature of the phone, though, is the Google maps app — with built-in turn-by-turn, voice-guided navigation. Replete with text-to-speech features, the maps are layered with traffic data and a satellite view. But here’s the best part. It’s free! Hear that? You don’t have to pay $10 a month as subscription or buy a pricey $100 TomTom app. You can just zip around with the Droid and Google Maps.

$200, motorola.com

8/10

Hack-o-Lantern Has Remote Control to Change Colors

remote-control-pumpkin2Halloween means time for costumes and some awesome nerd tricks with the pumpkin.

This hack-o-lantern has got to be one of the best we have seen this year. The lantern has a remote control to change its colors. Channel buttons 0-8 on the remote control help cycle through the colors of the rainbow. Button 9 activates an ‘angry pumpkin’ mode that flashes a red strobe for a few seconds, says Ian Lesnet who has published a how-to on instructables.com.

It isn’t an easy project. The idea uses among other things a circuit that decodes the remote control signals and a color changing LED module and you have to have a fair understanding electronics and programming to get it right.

For the rest of us, there’s always the Youtube video that shows the different color modes of the lantern.

For more great geeked out lanterns, check out the winners of SparkFun Electronics’ competition, which include a self-powered illuminated pumpkin that uses zinc and copper plates to light the LEDs, and a Silly String hack-o-lantern.

Mad Max Bike With Single-Cylinder Engine

bushranger

Forget your wussy electric bikes and silly Segways. This is what real men ride when they are feeling too delicate to actually pedal. It’s a Dunlop Bushrager mountain bike retrofitted with a gas engine.

Jeroen van Bergeijk came across this amazing bike mod while on tour in Australia. Found in Port Adelaide, the Mad Max bike has a one-cylinder engine mounted inside the frame with a gas tank up top. Best of all is that it still works as a proper bike, with gears, chain and chainring intact. The engine is instead hooked up to a sprocket on the other side of the rear wheel. Amazing, and surely a lot of fun.

Twitter SMS Arrives in India via Airtel

TwitterIf you are in India and an Airtel customer, the good news is that you can now send updates to your Twitter account from the mobile phone itself via SMS.

To get started, send an SMS message from the Airtel Mobile Phone to 53000 with “Signup” (if you are never used Twitter) or “Start” (if you already have an account on Twitter). The other option is that you can directly open the Twitter Devices page on twitter.com and link your  mobile phone number with your Twitter ID online (see video below).

You can then send an SMS text message to the 53000 number and it will post directly to your Twitter profile, and will be visible in the timeline of all your Twitter followers. Here’s an official list of all Twitter text commands that you can send from a mobile phone to interact with your Twitter stream.

If you are not using an Airtel connection, there’s no reason to worry as the Twitter-Airtel deal is not exclusive and will probably end after a month. Here’s the official word:

Twitter will be available in India on SMS only on the Airtel network. There is exclusivity for the same for 4 weeks, in which only Airtel consumers will be able to use the service on SMS across the nation. This period of exclusivity is something that we want to take advantage of and make sure that Brand Airtel can own the property Twitter in consumer mind space.

You save money because you don’t have to send an international SMS for using Twitter but the service is still expensive. Twitter doesn’t charge anything for sending updates but you’ll have to pay a buck to Airtel for every tweet that you send from the phone. To stop getting Twitter updates on your mobile phone, just send OFF, STOP, or QUIT command from your mobile phone to 53000 or use “ON” to start again.

Video: How to use Twitter on a mobile phone

Download All Your Documents from Google Docs as a Zip File

While Google Docs is brilliant, the only issue is that you need an active Internet connection to create new Office documents in Google Docs as well as for editing /reading old files that already exist in your Google account.

That’s a problem because, unless you use something like Google Gears, you won’t have access to your Google documents while you are in an airplane or are using an old computer that has Microsoft Office but no Internet connection.

Download Google Documents for Offline Use

Therefore the best option is that you download a copy of all your documents, PDFs, etc. from Google Docs and put them on a local hard-drive or USB stick so that you can at least read them which you are in offline mode.

While there are third-party tools that let you easily download Google Documents to the local drive in one go, the good news is that the batch export feature is now available in Google Docs by default so you don’t have to hunt for external tools to help you do so.

Select Google Documents for Exporting

export google docs

Just open your Google Docs account and select the documents that you want download locally.

Then use the Export option from “More Actions” and within minutes, all your Google documents will be available on the desktop as one large zip file. You may even convert Office files to PDF or HTML format before exporting them out of Google Docs.

Choose the Export Format – PDF, Word, etc.

download google documents

Advanced Disk Defragmenter Utility from Microsoft

disk defragmenter One of the reasons why your computer may become slow over time is because the files on the hard drive can become fragmented. Now what’s that?

Disk Fragmentation for Non-Techies

As you start filling your hard-drive with new programs, documents, and other files, the operating system tries to find vacant places on the hard-drive to place these files. Like an artist who breaks a tile into multiple pieces to form a mosaic, your computer will break these file into chunks (or fragments) and store them in different places across your hard drive.

When you load a program or open a file, the computer will have to first assemble these "fragmented" pieces thus decreasing the performance. And fragmentation is not just an issue with your computer’s hard disk but even removable devices like the USB Flash Drive or your external drives can also become fragmented with time.

Alternate Windows Disk Defragmenter from Microsoft

A Disk Defragmenter program helps because it will pre-arrange all the "fragmented" pieces of a file close together thus reducing the time it takes to open files or load programs on your computer.

Now almost every version of Windows includes a disk defragmenter utility but the problem with these built-in tools is that that will defragment the entire hard-drive at once and they’ll ignore files that are smaller than 64 MB. Luckily, Microsoft offers another free but lesser-known utility called Contig (short for contiguous) that lets you have more control over the defragmentation process.

Disk Defragmenter

What’s unique about Contig is that it lets you defragment individual files, folders, or the entire hard drive. You can run Contig from the command prompt but if that sounds a bit technical, you can also look at Power Defragmenter – an easy and more visual interface for Contig.

Using Power Defragmenter, you can visually select files, folders, or the drive you wish to defragment, and Power Defragmenter will internally use Contig to perform the defragmentation process. You may use Contig on machines running Windows XP, Vista and Windows 7.

For instance, if I were to defragment all the documents on my disk and none of the other files, the command* will be:

Contig.exe -v -s c:\Users\labnol\Documents\*.*


[*] You’ll need to run the utility as an administrator as it will throw an "Access denied" error.



And here’s a detailed output of a standard Contig command that tells you exactly what happens behind the scenes per file.



defragmentation process



Unlike other third-party defragmentation tools, Contig uses Windows’ internal defragmentation APIs so it won’t cause disk corruption, even if you terminate the program while its running.



Please note, however, that defragmentation is only recommended for traditional hard drives; computers using newer flash memory based solid-state drives should not use traditional defragmenters.  Even though file fragmentation may occur on these drives, it should not impact performance due to the nature of flash memory.  Additionally, defragmentation may actually decrease the life of a solid-state drive; however, they cannot cause this on a traditional platter-based hard drive.

Wednesday, August 19, 2009

Fun with Http Headers in ASP.NET MVC Action Filters - Kazi Manzur Rashid's Blog

Do you want your ASP.NET MVC application to auto redirect to a specific url after a certain interval, yes you can use javascript window.location, what about without javascript? Check this codes:
view source
print?
01.[AutoRefresh(ControllerName = "Home", ActionName = "About", DurationInSeconds = 10)]
02.public ActionResult Index1()
03.
04.[AutoRefresh(ActionName = "About", DurationInSeconds = 15)]
05.public ActionResult Index2()
06.
07.[AutoRefresh(RouteName = "ByFavoriteRoute", DurationInSeconds = 30)]
08.public ActionResult Index3()
09.
10.[AutoRefresh(DurationInSeconds = 45)]
11.public ActionResult Index4()

If the browsers is idle for the specified period, it will automatically redirect to that Action. if you do not specify any action/controller/route (Index4) it will auto refresh the current url. How? Well I am just using/abusing some http header, check it out:
view source
print?
01.[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
02.[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
03.public class AutoRefreshAttribute : ActionFilterAttribute
04.{
05. public const int DefaultDurationInSeconds = 300; // 5 Minutes
06.
07. public AutoRefreshAttribute()
08. {
09. DurationInSeconds = DefaultDurationInSeconds;
10. }
11.
12. public int DurationInSeconds
13. {
14. get;
15. set;
16. }
17.
18. public string RouteName
19. {
20. get;
21. set;
22. }
23.
24. public string ControllerName
25. {
26. get;
27. set;
28. }
29.
30. public string ActionName
31. {
32. get;
33. set;
34. }
35.
36. public override void OnResultExecuted(ResultExecutedContext filterContext)
37. {
38. string url = BuildUrl(filterContext);
39. string headerValue = string.Concat(DurationInSeconds, ";Url=", url);
40.
41. filterContext.HttpContext.Response.AppendHeader("Refresh", headerValue);
42.
43. base.OnResultExecuted(filterContext);
44. }
45.
46. private string BuildUrl(ControllerContext filterContext)
47. {
48. UrlHelper urlHelper = new UrlHelper(filterContext.RequestContext);
49. string url;
50.
51. if (!string.IsNullOrEmpty(RouteName))
52. {
53. url = urlHelper.RouteUrl(RouteName);
54. }
55. else if (!string.IsNullOrEmpty(ControllerName) && !string.IsNullOrEmpty(ActionName))
56. {
57. url = urlHelper.Action(ActionName, ControllerName);
58. }
59. else if (!string.IsNullOrEmpty(ActionName))
60. {
61. url = urlHelper.Action(ActionName);
62. }
63. else
64. {
65. url = filterContext.HttpContext.Request.RawUrl;
66. }
67.
68. return url;
69. }
70.}

Can’t think any proper usage of this action filter, may be you can use it for any iframe kind of page where you want to show some live statistics. Okay now let’s try one more time to abuse this Refresh header, this time it is a very common scenario.

You want your secured (marked as Authorized) actions to automatically redirect to login page when the session expires. Now try this:
view source
print?
01.[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
02.[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
03.public class AutoRedirectToLogin : ActionFilterAttribute
04.{
05. public override void OnResultExecuted(ResultExecutedContext filterContext)
06. {
07. string url = FormsAuthentication.LoginUrl;
08. int durationInSeconds = ((filterContext.HttpContext.Session.Timeout * 60) + 10); // Extra 10 seconds
09.
10. string headerValue = string.Concat(durationInSeconds, ";Url=", url);
11.
12. filterContext.HttpContext.Response.AppendHeader("Refresh", headerValue);
13.
14. base.OnResultExecuted(filterContext);
15. }
16.}

When the session expires it will automatically redirect to the login page without requiring the extra click from the user.

Word of Caution: Do not use the Refresh meta header if you want your url to include in the search engine index (verified in Google, not sure about the others). For example, your Page A wants to auto redirect to Page B, the Page A only has this header, in that case Page A will not be indexed.