Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

7.07.2013

Threat of Hackers in Healthcare

When Captain Zap hacked AT&T, millions of Americans saved money on their long distance phone call bills. Captain Zap successfully penetrated the AT&T network and went on to be part of the hacking hall of fame. His case is famous because AT&T didn't even know about the hack until after the next set of bills went out. By then the damage was done and Cap Zap was nowhere to be found. He was eventually caught but it took 18 grueling months of FBI hard work.

6.01.2013

Extensionless URL Rewrite in ASP.NET

URL rewriting is on the most powerful and important feature one can implement when developing websites. Among many benefits the most obvious ones are security and easy to follow paths. Rewriting rules hide the querystring variables being passed and make it easier for search engines and visitors to understand and follow the pages.

A typical rewrite scenario is where you have a URL like http://www.site.com/Default.aspx?bookID=12. You can turn this URL into http://www.site.com/Books/12.aspx. You can even go one step further and remove the aspx extension, turning the URL into http://www.site.com/Books/12.

How to implement it

In this post I will use URLRewritingNet as an example. You can use other providers if you like, but the process is almost the same.

Step 1: The DLL
Download the rewrite dll from http://www.urlrewriting.net/159/en/downloads.html. It is a zip file which contains the actual dll (UrlRewritingNet.UrlRewriter.dll).

Step 2: DLL Installation
Add the UrlRewritingNet.UrlRewriter.dll file into the Bin folder of your website.


Step 3: Web Config Setup
Enter the following section into the configuration's <configsection> so that it can be advertised.

<section name="urlrewritingnet" restartOnExternalChanges="true" requirePermission ="false"
type="UrlRewritingNet.Configuration.UrlRewriteSection,
UrlRewritingNet.UrlRewriter" />


Step 4: Register rewrite as an HTTP Module
Since we will handle all incoming requests with UrlRewritingNet, we will have to register the component as Http Module in the <system.web /> section.

<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>


Step 5: Enter the URL Rewrite rules
After the end of <configsection> and inside the <configuration/> we will add the rewrite rules. It is these rules which are responsible for handling your URLs.

In the following example our rule will take the book id URL and translate it to the inner querystring url.

 <urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString"
defaultProvider="RegEx" defaultPage = "default.aspx"
xmlns="http://www.urlrewriting.net/schemas/config/2006/07" >
<rewrites >
<add name="Rule1" provider="RegEx"
virtualUrl="^~/Book/(.+)$"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/Default.aspx?bookID=$1"
ignoreCase="true" />
</rewrites>
</urlrewritingnet>


Test run

If you visit /Book/12 it should translate to /Default.aspx?BookID=12

Troubleshooting

Rewrite rules with aspx extension work but the extension-less URLs give 404.
You may receive 404 (File or directory not found) error because under the Visual Studio webserver, every single request is passes through ASP.NET while in traditional IIS this is not the case. This can be solved by adding a UrlRewriteModule as a module in the <system.webServer> block.

<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>




Project files are available here: https://extensionlessurls.codeplex.com/SourceControl/latest

5.30.2013

Image displays in Firefox but not in IE

You have created a jpg image which looks really pretty in Firefox but the Internet Explorer shows a big fat "x". This boggled my mind for some time until I decided to look into it in detail. Lest you from keep guessing, the issue was CMYK format instead of RGB.

See the highlighted area in the image on the right indicating the CMYK mode. The CMYK mode (Cyan-Magenta-Yellow-Black) is good for media printing but is nothing something for the web display. Even though the RGB is intended for web graphics, the CMYK is still supported by majority of the browsers.

The reason some versions of IE may not display the image is because of the CMYK format. All you have to do is change the encoding mode (see image below) and all will be fine.


Contact Form

Name

Email *

Message *

 
POPULAR POSTS
TAG CLOUD