views:

19

answers:

1

Using asp.net mvc2 on vs2008 on local machine and hosting on a shared server at discountasp.net

Problem started when I could not make the .UTCNow deliver the correct "Office is open/closed" string as follows:

In the view user control:

<div><%=OfficeTimes.LondonOpenOfficeMessage() %></div>

And in the helper file:

public static class OfficeTimes
{
    public string LondonOpenOfficeMessage()
    {

        if (DateTime.UtcNow.Hour < 17 && DateTime.UtcNow.Hour > 7)
        {
            return "Office is currently closed";
        }
        else
        {
            return "Office is currently open";
        }
    }
}

so I changed the return string to the UTC (as below) to see if it was returning the correct time and still compiled as if it was the original.

public static class OfficeTimes
{
    public string LondonOpenOfficeMessage()
    {

        if (DateTime.UtcNow.Hour < 17 && DateTime.UtcNow.Hour > 7)
        {
            return DateTime.UtcNow.Hour.ToString(); //"Office is currently closed";
        }
        else
        {
            return DateTime.UtcNow.Hour.ToString(); //"Office is currently open";
        }
    }
}

I tried deleting the file...it still compiled.

All worked fine on the local machine.

Does anyone know the server does not refresh this helper file?

+1  A: 

In contrast to a web site project, ASP.NET MVC uses a web application project meaning that it needs to be compiled for your changes to take effect. When you are working on the local machine and you are running the site inside Visual Studio source code is automatically compiled and changes take effect. For your changes to take effect you need to deploy all the assemblies that are generated in the bin folder. No need to copy any source files to the server (except of course aspx and ascx pages).

Darin Dimitrov
thanks, I simply uploaded my compiled dll from local version and it worked fine.I never realised that the shared remote hosted server does not actually do the compile but now i have learned something new.
Paul Connolly