473,320 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

StringFormat issue.


Hello,
I have a webservice that performs some financial calculations. I use
String.Format("{0:n}) to presents the numbers in the culture specific
format.
This works fine on my dev machine which runs win xp in Danish.(running the
webservice locally and consumming it there).

My windows 2003 production server has language/culture Us english.
When i consume my webservice remotely from there, the formating goes all
wrong.

There is a setting under Language and regional options under control panel
that have changed to danish. This does not help me get my expected format .

Can someone tell what i'm doing wrong?

Many thanks
JJ
Jul 17 '06 #1
3 1391
Jens,

You might have to set the culture in your web.config file. Here is a
post online which details how to do that (as well as other culture related
info in ASP.NET):

http://www.dotnetjunkies.com/Tutoria...3D2EDD38B.dcik

On top of that, I hope that the numbers you are formatting are part of
other text that you are returning, and not the numbers themselves. If
anything, I would think you would pass a number back and let the client
decide how to format them.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jens Jensen" <jj@jensen.dkwrote in message
news:OQ**************@TK2MSFTNGP04.phx.gbl...
>
Hello,
I have a webservice that performs some financial calculations. I use
String.Format("{0:n}) to presents the numbers in the culture specific
format.
This works fine on my dev machine which runs win xp in Danish.(running the
webservice locally and consumming it there).

My windows 2003 production server has language/culture Us english.
When i consume my webservice remotely from there, the formating goes all
wrong.

There is a setting under Language and regional options under control panel
that have changed to danish. This does not help me get my expected format
.

Can someone tell what i'm doing wrong?

Many thanks
JJ

Jul 17 '06 #2
Hi Jens,
My windows 2003 production server has language/culture Us english.
When i consume my webservice remotely from there, the formating goes all
wrong.
Like Nicholas already pointed out, your best bet is probably to choose a
culture for your application and set that in web.config.

The reason you are seeing this change in cultures in your production server
is that (assuming you are using IIS as your web server) the so-called
regional settings are set on per-user basis. When IIS runs your web service,
it does so in the context of another user account, which you can configure
with the IIS Admin tool.

For a reference, you might also want to check this document about ASP.NET
application Worker Process Isolation Mode:

http://www.microsoft.com/technet/pro....mspx?mfr=true

And, in case you are totally unsure about the configuration on your
production server, create a simple .ASPX page that contains the following:

----------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

<head runat="server">
<title>Who Am I?</title>
</head>
<body>
<h1>Who Am I?</h1>
<pre><%= GetCurrentUserInfo() %></pre>
</body>
</html>
----------------------------

And for the page.aspx.cs file, type in the following code:

----------------------------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Security.Principal;

public partial class _Default : System.Web.UI.Page
{
public string GetCurrentUserInfo()
{
StringBuilder info = new StringBuilder();
WindowsIdentity currentUser = WindowsIdentity.GetCurrent();
info.Append("Username: "+currentUser.Name + "\r\n");
info.Append("SID: " + currentUser.User.Value + "\r\n");
return info.ToString();
}
}
----------------------------

At runtime, the GetCurrentUserInfo() method will report data similar to the
following:

----------------------------
Who Am I?

Username: SAPPHIRE\ASPNET
SID: S-1-5-21-2052711402-412623190-839572195-1021
----------------------------

Hope this helps!

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethis.dystopia.fi
http://www.saunalahti.fi/janij/
Jul 17 '06 #3
Thank you all,
This was very helpful.. I will go experiement with all these qualified
helps.

Thanks
JJ
Jul 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and...
7
by: George Hester | last post by:
Please take a look at this google artcle: http://groups.google.com/groups?hl=en&lr=&frame=right&th=55d6f4b50f5f9382&seekm=411f370d%241%40olaf.komtel.net#link9 The op was having trouble with...
2
by: Anthony Cuttitta Jr. | last post by:
We have an application that outputs several different graphs from data downloaded from our AS400. The application has worked without (this) issue for several months now, but just recently, the...
0
by: Kevin Spencer | last post by:
Hi all, I am working on a service that uploads METAR weather information to the National Weather Service FTP site. The service I'm authoring is hosted on a Windows 200 server, and the NWS FTP...
0
by: John Richardson | last post by:
I have a DataGridLabelColumn I've made by overriding a DataGridColumnStyle object. (based on an MSDN article by Chris Sano). In the Paint method, I use a StringFormat object, and pass that to a...
2
by: Ben Rush | last post by:
Hello World, Okay, I have spent the day browsing the newsgroups and reading up on article after article concerning ViewState corruption and so forth, and I have a couple questions. We...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
0
by: Charles Leonard | last post by:
I am having yet another issue with Windows Server 2003. This time, the web service (a file import web service) appears to run except for one odd message: "ActiveX component can't create object". ...
4
by: Paul | last post by:
Hi, I've been struggling with this today, I'm developing a DotNet2.0 website in C# that needs to call a long running data query. Obviously this is a good candidate for an Asynchronous call, so...
13
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.