Friday, November 30, 2012

URL rewriting

URL rewriting is a software running on web application framework. This software is used to generate more user friendly URL rather than a computer generated URL which are sometimes unreadable. 

Websites with dynamic content are often generated with URLs with computer generated content with query string parameters. URL rewriting can be applied in these situations to generate more readable URL. 

Ex: 
http://www.example.com/Content/Posts.php?Yr=2012&Mon=11&Day=18

this URL can be rewritten as 
http://www.example.com/Content/2012/11/18/article1

Benefits of URL Rewriting

  • More cleaner user friendly URLs
  • Query strings can be used to compromise information about the websites. URL rewriting minimizes this risk
  • Prevent inline linking
Web Frameworks
Almost all the popular web frameworks supports URL rewriting. Following are some of them.
  • Apache HTTP Server
  • IIS
  • Ruby on Rails
  • Java EE
  • Django
  • Codeigniter

Following are some of useful links for URL Rewriting

Thursday, November 29, 2012

Get Windows User ASP.NET


When developing ASP.NET applications, there might be situations where you need to know who is the currently logged in Windows user in to do things like authorization, authentication etc. These might b e useful when you are developing applications for the internal use within an organization. 

Luckily ASP.NET has few options built in to get the currently logged in user. You can use one of the following code snippet to get the current user.

1.

string user = HttpContext.Current.User.Identity.Name;


2. 

string user = Thread.CurrentPrincipal.Identity.Name;

2nd opiton only applies when you have specified in your web applications config file that the authentication mode is windows 

This is pretty straight forward and simple.