Tonny FuseinOur U.S. data center is located in California, so the web and database servers have their timezone set to Pacific Time.

One of the questions we get quite often is how to modify server time so it matches the time zone of the customer or users. Unfortunately, the answer is — you can’t. The web server can only run in one time zone, so the time is going to be “off” in the other 39 time zones.

What you can do to work around this is convert the server time to your local time. .NET makes this easy with a built-in TimeZoneInfo class that can be used to convert one time zone to another.

This sample shows how to convert server time from Pacific Standard Time zone (GMT -7:00) to Mountain Standard Time (GMT -6:00):

<%@ Page Language="C#" AutoEventWireup="true"%>
<script language="C#" runat="server">
  protected DateTime GetCurrentTime()
        {
            DateTime serverTime = DateTime.Now;
            DateTime _localTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(serverTime, TimeZoneInfo.Local.Id, "Mountain Standard Time");
            return _localTime;
        }

  protected void Page_Load(object sender, EventArgs e)
        {
		Response.Write(GetCurrentTime());
        }
</script>

And this is how to get the TimeZoneId on the server:

<%@ Page Language="C#" AutoEventWireup="true"%>
<script language="C#" runat="server">
  protected void Page_Load(object sender, EventArgs e)
        {
		   foreach (TimeZoneInfo zoneID in TimeZoneInfo.GetSystemTimeZones())
            {
                Response.Write(zoneID.Id + "<br/>");
            }
        }
</script>

Visit DiscountASP.NET to learn more about our ASP.NET hosting services.

 

Managing an FTP site as a local drive

On July 17, 2012, in How-to, by Tonny Fusein

Tonny FuseinThis article will show you how to manage your FTP site by mounting it as a local drive on your computer. This gives you the flexibility of moving the files around like you would with normal windows files.

Download and install the Netdrive application on your local computer. This application is free for non-commercial use.

Once download and installed, configure Netdrive to access your site via FTP. These are the same settings you would use for any other FTP clients.

Put a check mark on the “automatic login” options so the FTP will be mounted as a Windows drive every time you start Windows.

Once connected, you will see that the FTP root of your site is now mounted as a Windows drive with the drive letter assigned by the Netdrive app.

To unmount the drive, simply go back to Netdrive and hit disconnect. Don’t be alarmed by the drive size;  Netdrive has it fixed at 512GB, so this won’t reflect your actual disk space on the server.

 

Download your site backups automatically

On April 24, 2012, in Technical, by Tonny Fusein

Tonny FuseinThis article will discuss the general topic of creating an automated backup of your site. It is not a tutorial or step by step instructions.

DiscountASP.NET does not currently provide an interface such as a file manager to backup site contents and download them to your local computer. Most customers have backups of their site, but if you don’t have a backup of your site – that could potentially be disastrous if your site were compromised for example.

“So how do I download a backup automatically? I don’t want to manually FTP every day.”

.NET framework comes with a system.net class that has capability of initiating an FTP session. It can determine the file size and download files to your local computer. There are many articles and guides available out there, and if you can  create the function with ASP.NET, you can pair it with the task scheduler (in the DiscountASP.NET Control Panel) to call the page at a certain time of day or use a .NET timer to initiate the page call to initiate the actual backup automation procedure.

“But I’m not a coder, so how do I pull down my files automatically?”

Enter FTP automation software.

There are tons of these programs available, ranging from free to very expensive. I have tested some of them and the one that stood out the most was ScriptFTP. It is easy to use, dependable and it won’t cost you an arm and a leg.

After downloading and installing, simply create a script file (upload, download, sync, etc) and run it from the application. The main selling point for this software is the internal scheduler feature that is capable of running your custom ftp script at certain intervals. You can try ScriptFTP free for 30 days, but after that, this application worth every penny of the $29.95 price.

Finally, with the recent hype surrounding cloud, many of the big boys are offering free cloud storage solutions (iCloud, Google Docs, Microsoft Skydrive, etc.). In fact, Microsoft is offering free 7gb storage on Skydrive. We can incorporate this with the application’s upload capability to push the files to cloud storage after successful download so now you have a site backup available anytime, anywhere.

p.s.

I’m not related to the developers of this software in any way. It’s just a great tool that I wanted to tell you about.

 

Root redirection to subdirectory

On April 18, 2012, in How-to, Technical, by Tonny Fusein

Tonny FuseinIn a previous post we showed you how to force a normal HTTP call to HTTPS. Today we’ll show you how to redirect from root to subdirectory.

The default page/homepage in your root directory would normally be displayed when someone makes an HTTP request to your site. But what if you installed an application in a subdirectory and want to use that application as a starting point? For example, WordPress is installed in a subdirectory, and you want the WordPress application to be the default starting point when someone types your URL.

There is sample code available in our Knowledge Base to redirect using .NET code. This requires the page to load and compile before the redirection happens. Now I want to show you redirection using the IIS manager/web.config instead. This should redirect the request faster as the redirection happens as soon as the HTTP request received by IIS.

Using IIS7 manager, connect to IIS and navigate to the URL rewrite module. Add a blank rule and name it as you wish. Only two variables are needed; match URL pattern and actions.

The parameters are as follows:

Match URL section:
Requested URL : Matches the pattern
Using : Regular Expression
Pattern : ^$

Action section:
Action Type : redirect
redirect URL : your relative subdirectory path e.g., if nopCommerce is installed in a subdirectory you would use /nopCommerce
redirect type : permanent

screesnhot

This will write to your web.config and add this section:

<system.webServer>
<rewrite>
<rules>
<rule name="redirect" stopProcessing="true">
<match url="^$" />
<action type="RedirectToSubdir" url="/nopCommerce" />
</rule>
</rules>
</rewrite>
</system.webServer>

That’s all there is to it.

Remember than any changes you make with IIS Manager are written to web.config, so overwriting web.config in the future can remove those changes.

 

Visual Studio 2011 Ultimate beta overview

On March 20, 2012, in Technical, by Tonny Fusein

Tonny FuseinWith the release of Visual Studio 2011, I had a chance to download the Ultimate (beta) version and install it on my computer to see what this new Visual Studio version has to offer. The download and install process took about 2 hours to finish (9GB download from Microsoft site). It comes bundled with .NET framework 4.5 which also includes some improvements and new features.

As soon as Visual Studio runs on your computer you will notice the new look of its interface. Microsoft revamped the older Visual Studio look and gave it new icons and colored theme. In fact, you can choose between light and dark theme from option menu according to your taste.

Visual Studio 2011 also supports HTML5 validation and CSS3 natively; no need to install an additional update package like you had to with Visual Studio 2010. There are also some new option menus selectable from top menu bar (XMl, SQL, Menu test) and a new “quick launch” feature accessible from top right of the interface which could be used as a shortcut for commands like open, new, add, etc. You can also choose which local browser is launched when “View in browser” is selected from the menu shortcut, which is very convenient.

Other new features in Visual Studio 2011 include a Graphic tool for basic 3D model editing and an enhanced Team Explorer function; you can now request code reviews at any point in the project lifecycle.

 

Visual Studio 2011 ultimate Beta; new menus and HTML5 validation option

Visual Studio 2011 Ultimate Beta edition with dark color theme

 
iBlog by PageLines