Friday, June 29, 2012

Converting AD UTC time to DateTime

Convert local time to UTC

TimeZoneInfo.ConvertTimeToUtc(DateTime.Now.AddDays(15)).ToFileTimeUtc()
 
Result
129867569963464980

Convert UTC time to Local time

TimeZoneInfo.ConvertTimeToUtc(DateTime.Now)

Result:
{6/29/2012 4:29:09 PM}
    Date: {6/29/2012 12:00:00 AM}
    Day: 29
    DayOfWeek: Friday
    DayOfYear: 181
    Hour: 16
    Kind: Utc
    Millisecond: 954
    Minute: 29
    Month: 6
    Second: 9
    Ticks: 634765841499549823
    TimeOfDay: {16:29:09.9549823}
    Year: 2012

Wednesday, June 20, 2012

Deploy ASP.NET MVC App on Windows XP (IIS 5.1)

Thanks to
http://itscommonsensestupid.blogspot.com/2008/11/deploy-aspnet-mvc-app-on-windows-xp-iis.html

Deploying ASP.NET MVC application on Windows XP is definitely not easy; there are a lot of settings that need to be tuned. Not only that the application must be changed as well.

The first thing to do is to add the relevant mapping to the Application Configuration of the MVC application. To do this, one must go to Start-> Control Panel-> Administrative Tools-> Internet Information Services. Then, one should click on  the Internet Information Services icon, right-click on the MVC application, and select Properties. On the Virtual Directory Tab, choose Configuration, as shown below:



After clicking on the Configuration panel, choose the Executable to be the aspnet_isapi.ll, and the extension to be ".*", make sure that the "check that file exists" is unchecked. If the OK button is disabled, you must click on the textbox for the Executable, and only then the OK button is enabled.

Click OK all the way to close the Administrative tools.

One must also add a route to the RegisterRoutes static function. Here is the syntax that is compatible with ASP.NET MVC Beta
?
1
2
3
4
5
6
7
routes.Add(new Route
(
"{controller}.mvc/{action}/{id}",
new RouteValueDictionary(new { action = "Index", id = (string)null }),
new MvcRouteHandler()
));

Look through your MVC application, make sure that you don't have any hardcode reference to controller class or action method. If you are using

?
1

"/Home/uploadfiles"></form>


Make sure you change it to

?
1
"<%=Url.Action(new{controller=" home",="" })%>"=""></form>


If you have

?
1