Previous Next

Thread: IIS 5.1 config and dates

Last post 06-25-2008 7:41 AM by LockH. 7 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (8 items)

Sort Posts:

  • 05-22-2007, 9:48 AM

    • LockH
    • Top 500 Contributor
    • Joined on 03-25-2007, 10:58 AM
    • Scotland
    • Posts 11
    • LockH

    IIS 5.1 config and dates

    I have IE7 on my screen with two tabs showing the same page, on my local machine. In one tab it works as intended, in the other it does not. The difference is that the first tab was opened by "view in browser" inside VS2005, the url shows as http://localhost:1252/mypage.

    I manually opened the second tab and typed in the url of the page as http://localhost/mypage  

    This is a simple ASP.NET 2 page, displaying the current date and the culture, UIculture, and short and long date format settings.

    Run from VS2005 by right-click and View in Browser it shows:

    22/05/2007
    Culture is set as English (United Kingdom)
    UICulture is set as English (United Kingdom)
    Short Date Format is set as dd/MM/yyyy
    Long Date Format is set as dd MMMM yyyy

    Run from IE7 url bar it shows:

     5/22/2007
    Culture is set as English (United Kingdom)
    UICulture is set as English (United Kingdom)
    Short Date Format is set as M/d/yyyy
    Long Date Format is set as dd MMMM yyyy

    The date is displayed differently, and the short date format string is different, even though the culture and UIculture are always English (United Kingdom). In short, it works from VS, but not directly from IE7. The short date format is not being localized with the culture as you would expect. 

     

    This is on XP Pro SP2, VS2005 and IIS 5.1.

    I tried it in VWD Express too. It works when run on VWDs internal server, but not when run in a separate copy of IE7 using IIS.

     

    Is this an IIS 5.1 configuration issue, rather than an ASP.NET coding problem?

     

    Is there any way to set the date format in the config, other than using the culture and UICulture? 

    I tried to set the short date format in code, but got a "read only" message.

     

    Code follows:

    protected void Page_Load(object sender, EventArgs e)

    {

    DateTime myDT = new DateTime() ;
    myDT = DateTime.Today;

     

    Response.Write(myDT.ToString("d"));

    Response.Write("<br /> Culture is set as " + System.Globalization.CultureInfo.CurrentCulture.EnglishName.ToString());

    Response.Write("<br /> UICulture is set as " + System.Globalization.CultureInfo.CurrentUICulture.EnglishName.ToString());

    Response.Write("<br /> Short Date Format is set as " + System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern.ToString()); Response.Write("<br /> Long Date Format is set as " + System.Globalization.DateTimeFormatInfo.CurrentInfo.LongDatePattern.ToString());

    }

    If a post helps to solve your problem, please mark as Answer.

    I'm still confused, but now I'm confused on a higher plane.
  • 05-25-2007, 1:47 PM In reply to

    • LockH
    • Top 500 Contributor
    • Joined on 03-25-2007, 10:58 AM
    • Scotland
    • Posts 11
    • LockH

    Re: IIS 5.1 config and dates

    No ideas at all?

     

    If a post helps to solve your problem, please mark as Answer.

    I'm still confused, but now I'm confused on a higher plane.
  • 05-29-2007, 9:06 AM In reply to

    Re: IIS 5.1 config and dates

    Hello again,

    I'm a bit confused.

     
    However it looks to me that the page opened by "view in browser" inside VS2005 was from the ASP.NET Development Server.

    http://localhost:1252/mypage.

    And the second page opened directly by typing the URL in IE address bar seems returned from IIS Server. 

    http://localhost/mypage 

     

    If so you might have different versions of .aspx files, the two pages are actually came from different locations. Please check both the virtual directory in IIS Manager and the website project folder in Visual Studio 2005 if you have two versions of pages?

     

    Zhao Ji Ma
    Sincerely,
    Microsoft Online Community Support

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
  • 05-29-2007, 1:48 PM In reply to

    • LockH
    • Top 500 Contributor
    • Joined on 03-25-2007, 10:58 AM
    • Scotland
    • Posts 11
    • LockH

    Re: IIS 5.1 config and dates

    Zhao Ji Ma - MSFT:

    Hello again,

    I'm a bit confused.

    Hi, thanks for responding. 

    I know that feeling well. 

    Zhao Ji Ma - MSFT:


    However it looks to me that the page opened by "view in browser" inside VS2005 was from the ASP.NET Development Server.

    http://localhost:1252/mypage.

    And the second page opened directly by typing the URL in IE address bar seems returned from IIS Server. 

    http://localhost/mypage 

     

    Agreed - I get different results from the development server and from IIS 5.1 

    Zhao Ji Ma - MSFT:

    If so you might have different versions of .aspx files, the two pages are actually came from different locations. Please check both the virtual directory in IIS Manager and the website project folder in Visual Studio 2005 if you have two versions of pages?

    I am absolutely certain that there is only one version of the page. I created a new copy of the page with a new name in one place only, and viewed it in both the development server and in IIS. Different results, as described. 

     

     

    If a post helps to solve your problem, please mark as Answer.

    I'm still confused, but now I'm confused on a higher plane.
  • 05-30-2007, 5:46 PM In reply to

    • LockH
    • Top 500 Contributor
    • Joined on 03-25-2007, 10:58 AM
    • Scotland
    • Posts 11
    • LockH

    Re: IIS 5.1 config and dates

    I have been chipping away at this date problem for a while, where I get different results in the VS development server and in IIS5.1.

    It works in VS, it doesn't work in IIS.

    I was coming to suspect a bug in IIS 5.1; nothing else was different.

    But isn't it the case that IIS and the VS development server run as different users? 

    Do I remember right that the IIS one is IISUSR, and the VS server one ASPNET?

    So maybe the problem is that these users have different cultures set, or the settings for one of those users (the IIS one) is corrupted?

    But that raises the question, how can I change the settings - especially the short date format - for that user?

    If a post helps to solve your problem, please mark as Answer.

    I'm still confused, but now I'm confused on a higher plane.
  • 06-01-2007, 2:54 AM In reply to

    Re: IIS 5.1 config and dates

    Hi, 

    I've verified this with IIS 6 and the ASP.NET Website Development Server. The results from both are the same either with Anonymous Access or Windows Authentication enabled.

     5/22/2007
    Culture is set as English (United Kingdom)
    UICulture is set as English (United Kingdom)
    Short Date Format is set as M/d/yyyy
    Long Date Format is set as dd MMMM yyyy

    I think I get to verify it with IIS 5.1 too. Thanks for the information.
    Zhao Ji Ma
    Sincerely,
    Microsoft Online Community Support

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
  • 02-11-2008, 1:40 AM In reply to

    • DragonWolf
    • Not Ranked
    • Joined on 02-11-2008, 6:31 AM
    • Posts 1
    • DragonWolf

    Re: IIS 5.1 config and dates

    Hi JiMa,

     I have seen this problem recently with IIS 5.1 with VS2005. Have you done any futher investigation?

  • 06-25-2008, 7:41 AM In reply to

    • LockH
    • Top 500 Contributor
    • Joined on 03-25-2007, 10:58 AM
    • Scotland
    • Posts 11
    • LockH

    Re: IIS 5.1 config and dates

    An update:

    I tried installing the same VWD and SQL and WinXP Pro on different machines.

    Everything worked as you would hope on a new machine, on the old machine it continued to fail in IIS5.1 but work in the dev server.

    I went to regedit and searched the registry for date format strings. I found one M/d/y on the old dev machine, not present on the new install. That machine had been in use for 5 years, a lot of different versions of a lot of different things had been installed and removed, I didn't know where that format string had come from. I took some notes, then deleted it, and the problem went away.

    That was nearly a year ago. The project has run on a variety of other machines since, including Vista and Win2003, and the bug has not returned. But I have seen other people on asp.net/forums with what seems to be the same problem, all using XP pro IIS 5.1 with non-us date formats.

     

    If a post helps to solve your problem, please mark as Answer.

    I'm still confused, but now I'm confused on a higher plane.
Page 1 of 1 (8 items)
Page view counter