简体   繁体   English

如何添加自定义标题以请求html页面?

[英]How to add custom headers to request html page?

I have two ASP.NET solutions. 我有两个ASP.NET解决方案。 Bot are running under different IIS websites. Bot在不同的IIS网站下运行。 Lets say first one is called SOLUTION-A (this is a intranet portal) and the other one is SOLUTION-B (custom business process solution). 可以说第一个称为SOLUTION-A(这是一个Intranet门户),另一个是SOLUTION-B(自定义业务流程解决方案)。

I want to add custom header to SOLUTION-A before i call SOLUTION-B via simple html link like 我想在通过简单的html链接调用SOLUTION-B之前向SOLUTION-A添加自定义标头

X-PERMS_GUID X-PERMS_GUID

X-CALLER_GUID X-CALLER_GUID

Then in SOLUTION-B i want to read those two custom header from the request. 然后在解决方案B中,我想从请求中读取这两个自定义标头。

How can i do this? 我怎样才能做到这一点?

In c# you can add custom header like so: 在c#中,您可以添加自定义标头,如下所示:

var client = new HttpClient()
client.DefaultRequestHeaders.Add("X-PERMS_GUID","1");

Read custom header: 读取自定义标题:

IEnumerable<string> headerValues = request.Headers.GetValues("X-PERMS_GUID");
var id = headerValues.FirstOrDefault();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM