我有一个Windows Server 2008 R2系统配置了默认的区域设置(没有覆盖格式或任何东西),它设置为en-US.
当我询问以下内容时: System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat
它将DateSeparator列为-(破折号)而不是/(斜杠).所以DateTime.Now.ToString()看起来像这样:
01-30-2015.
另外,CurrentThread.CurrentCulture.ToString()="en-US"
我完全不知道这是怎么可能的,但更重要的是,我想知道.NET是否有某种类型的语言环境覆盖,可以通过某种方式进行配置?
系统区域和语言设置是正常的,尚未更改.非常感谢任何帮助,谢谢.
这是诊断信息的代码.它是在asp.net页面上的asp.net中运行的.
Current Date Time: <%= DateTime.Now.ToString() %>
Current Short Date: <%= DateTime.Now.ToShortDateString() %>
Current Culture: <%= System.Threading.Thread.CurrentThread.CurrentCulture.ToString() %>
Current UI Culture: <%= System.Threading.Thread.CurrentUICulture.ToString() %>
DateTimeFormatInfo invariant = CultureInfo.InvariantCulture.DateTimeForamat;
DateTimeFormatInfo uiThread = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat;
DateTimeFormatInfo thread = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat;
Type type = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.GetType();
foreach( var prop in type.GetProperties()) {
<%= prop.Name %>
<%= prop.GetValue(invariant, null) %> <br/>
<%= prop.GetValue(uiThread, null) %> <br/>
<%= prop.GetValue(thread, null) …Run Code Online (Sandbox Code Playgroud) 我正在编写一个http自动化框架,我的问题是与经过身份验证的http 安全连接进行通信.在做了一些研究之后,我发现了C#中的SslStream对象,它可以很容易地与我现有的客户端架构集成.问题是; 尽管能够验证我与给定Web服务器的连接,但任何"GET [website] HTTP/1.1"命令似乎只返回标题而不是实际的网页.
我有一种感觉,我没有正确地形成我的网络请求,但我真的不知道.我整个上午一直在做研究,在这个特定的问题上找不到很多资源.这是我项目的代码示例:
private IAsyncResult Request(HttpRequestToken token, ReceiveEvent callback)
{
if (token == null)
throw new Exception("Error. No request information provided. Aborting operation.");
//Setup the TCP Information. (_port is set to 443 for SSL purposes)
var client = new TcpClient(token.Host, _port);
//Get a handle to a networkstream for writing data.
var requestStream = new SslStream(client.GetStream(), false, null);
//Authenticate the request
requestStream.AuthenticateAsClient(token.Host);
//Translate the data.
byte[] sendBuffer = UTF8Encoding.UTF8.GetBytes(token.ToString());
//NOTE: The results of the above …Run Code Online (Sandbox Code Playgroud)