Tag: header

使用StreamWriter将标头添加到CSV输出文件中

我正在尝试将标头添加到CSV文件中,作为标题,我希望在WriteLine使用变量名称。 在这里你有我的代码: using (StreamWriter file = new StreamWriter(fs)) { for (int s = 0; s < pr.Length; ++s) { string[] UsersIDS = new string[] {""}; UsersIDS = db.GetUsersList(pr[s].ProjectID); file.WriteLine( pr[s].ProjectID + '"' + ',' + '"' + pr[s].ProjectTitle + '"' + ',' + pr[s].PublishStatus + '"' + ',' + UsersIDS.Length); } }

身份validation限制扩展标头大小

我有一个连接到身份服务器4身份服务器的Asp .net mvc应用程序。 当我发布应用程序时,我对此错误感到不满。 上游从上游读取响应头时发送了太大的头 在上游读取响应头时,我跟踪到这个上游发送了太大的头 我无法改变配置,系统管理员已声明我们需要缩小标头。 看了之后我就不得不同意这些标题有点广泛。 应用程序中的Startup.cs services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme) .AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, options => { options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.Authority = Configuration[“ServiceSettings:IdentityServerEndpoint”]; options.RequireHttpsMetadata = true; options.ClientId = Configuration[“ServiceSettings:ClientId”]; options.ClientSecret = Configuration[“ServiceSettings:secret”]; options.Scope.Add(“testapi”); options.ResponseType = “code id_token”; options.SaveTokens = true; options.GetClaimsFromUserInfoEndpoint = true; options.Events = new OpenIdConnectEvents() { […]

WebClient设置标头

我如何在webClient类中设置标题? 我试过了: client.Headers[“Content-Type”] = “image/jpeg”; 抛出WebException 我的代码: WebClient client = new WebClient(); client.Headers.Set(“Content-Type”, “image/png”); client.Headers.Set(“Content-Length”, length); client.Headers.Add(“Slug”, name); NameValueCollection nvc = new NameValueCollection(); nvc.Add(“file”, FileContents); Byte[] data = client.UploadValues(url, nvc); string res = Encoding.ASCII.GetString(data); Response.Write(res);

更改devexpress网格控制列标题标题

海全, 如何使用c#更改devexpress gridconrol column header caption 。 请帮忙

获取没有Content-Disposition的文件名

我正在寻找这个问题的解决方案好几天,我找不到任何。 我想从带有webclient的web服务器下载文件。 下载工作正常,但我无法获得真正的文件名,这对我来说非常重要。 我在许多主页上看过,文件名应该保存在Content-Disposition-Header中。 不幸的是,这个网站的标题是空的。 我试着用它: string header_contentDisposition =””; using (WebClient client = new WebClient()) { client.OpenRead(link); header_contentDisposition = client.ResponseHeaders[“Content-Disposition”]; MessageBox.Show(header_contentDisposition); } 此标题中没有保存信息。 如果我尝试使用我的浏览器(IE,Opera,Chrome)下载文件,则文件名将显示在filedialog中,因此必须将其保存在某处。 你能想象我能在哪里找到它吗? 编辑:我无法从URL中提取它,因为链接是由php生成的 http://www.example.com/download.php?id=10

在C#中从WebClient读取响应头

我正在尝试创建我的第一个Windows客户端(这是我的第一个post),应该与“Web服务”进行通信,但是我有一些麻烦来阅读回复的响应标题。 在我的响应字符串中,我收到了一个很好的JSON文档(这是我的下一个问题),但我无法“查看/读取”响应中的标题,只有正文。 下面是我正在使用的代码。 WebClient MyClient = new WebClient(); MyClient.Headers.Add(“Content-Type”, “application/json”); MyClient.Headers.Add(“User-Agent”, “DIMS /0.1 +http://www.xxx.dk”); var urlstring = “http://api.xxx.com/users/” + Username.Text; string response = MyClient.DownloadString(urlstring.ToString());

Datagrid前景色不起作用

我有一个显示二维数据的简单数据网格。 我在测试项目中尝试过,结果很好。 这是xmal: 以及相关的事件代码: private void DataGrid_LoadingRow(object sender, System.Windows.Controls.DataGridRowEventArgs e) { e.Row.Header = “R” + ((e.Row.GetIndex()) + 1).ToString(); } private void dg_AutoGeneratingColumn(object sender, System.Windows.Controls.DataGridAutoGeneratingColumnEventArgs e) { string str = e.PropertyName; int num = int.Parse(e.PropertyName); e.Column.Header = “C” + (num + 1).ToString(); } 然后我必须把它放在我的真实项目中,这是一个风格的窗口。 所以我把同样非常简单的xaml(在这里添加背景和前景,我有一个渐变背景),以便xamls是: 效果是: 所以简而言之,FOREGROUND并没有设置在任何部分。 那是: 细胞 行标题 列标题 无处可去。 谁能告诉我为什么? 先谢谢帕特里克

winform – 合并datagridview头文件

我在winForm中合并datagridview标头时遇到问题。 我用这个代码: void dataGridView1_Paint(object sender, PaintEventArgs e) { Rectangle r1 = dataGridView1.GetCellDisplayRectangle(2, -1, true); Rectangle r2 = dataGridView1.GetCellDisplayRectangle(3, -1, true); r1.X += 1; r1.Y += 2; r1.Width += r2.Width – 2; r1.Height -= 6; using (SolidBrush br = new SolidBrush(dataGridView1.ColumnHeadersDefaultCellStyle.BackColor)) { e.Graphics.FillRectangle(br, r1); } //draw text using (SolidBrush br = new SolidBrush(this.dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor)) { StringFormat sf […]

在C#代码中重用.h文件中的define语句

我有C ++项目(VS2005),其中包含#define指令中版本号的头文件。 现在我需要在双C#项目中包含完全相同的数字。 最好的方法是什么? 我正在考虑将此文件包含为资源,然后在运行时使用正则表达式解析它以恢复版本号,但也许有更好的方法,您如何看待? 我不能在.h文件之外移动版本,也建立系统依赖于它而C#项目是应该适应的。

将标头添加到简单Web服务请求

我有一个控制台应用程序,我只需通过单击写入添加Web引用并使用“添加服务引用”,然后将我的.Config文件更改为: 所以,一切都很好,似乎我可以成功使用该服务,但服务文档说我需要在请求的标题上设置用户名和密码,这是文档的示例: user password … 那么如何在标题中添加用户名和密码? 有什么建议吗?