[英]How to generate URL in ASP.NET / C# for a Single Sign-On (SSO) using JSON?
I have the following code that serialize a JSON string: 我有以下代码可序列化JSON字符串:
string token = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); // token creation
DateTime Minutes = DateTime.Now.AddMinutes(25);
StringEncryption stringEncryption = new StringEncryption();
var sso = "MY_SSO_KEY";
OnlineProfile onlineProfile = new OnlineProfile();
onlineProfile.first_name = "John";
onlineProfile.last_name = "Doe";
onlineProfile.email = "johndoe@multisite.com";
onlineProfile.expires = Minutes.ToString();
onlineProfile.url = "https://www.multisite.com";
onlineProfile.SSO = stringEncryption.Encrypt(sso);
onlineProfile.signature = stringEncryption.SignData(token);
JsonSerializer serializer = new JsonSerializer();
serializer.Converters.Add(new JavaScriptDateTimeConverter());
serializer.NullValueHandling = NullValueHandling.Ignore;
using (StreamWriter sw = new StreamWriter(@"c:\json.txt"))
using (JsonWriter writer = new JsonTextWriter(sw))
{
serializer.Serialize(writer, onlineProfile);
}
The code above generates the following JSON data output: 上面的代码生成以下JSON数据输出:
//{"email":"johndoe@multisite.com",
//"expires":"10/11/2018 14:25:00 PM",
//"first_name":"John",
//"last_name":"Doe",
//"url":"https://www.multisite.com",
//"SSO":"MY_SSO_KEY_ENCRYPTED",
//"signature":"TOKEN"}
And with that JSON data would like to form the following url: 并使用该JSON数据来形成以下网址:
http://www.multisite.com/sso?sso=MY_SSO_KEY_ENCRYPTED&signature=TOKEN
How can I form the url above? 我怎样才能形成上面的网址? Thanks a lot for the help! 非常感谢您的帮助!
try the UrlBuilder 尝试使用UrlBuilder
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.