我已经在阳光下尝试了所有方法来访问 AppSettings,但我无法让它工作。
我有一个需要访问网络 AppSettings 的类库。我检查过,没有 要导入的“System.Collections.Specialized.NameValueCollection” 。
有人有什么想法吗?
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Configuration;
public static class httpresponsebase_setoauthfromcookie
{
public static void SetOauthFromCookie(this HttpResponseBase response, string verify,
string token, string tokenSecret,
string userName,
bool isTwitter)
{
string pas = WebConfigurationManager.AppSettings["cryptpass"],
crypt = ((verify.Length > 3 ? (verify + ":") : "twit") + token + ":" + tokenSecret).Encrypt(pas);
//
var cookie = new HttpCookie(userName + (isTwitter ? "twitter" : "linkedin"), HttpServerUtility.UrlTokenEncode(Convert.FromBase64String(crypt)));
cookie.Expires = DateTime.Now.AddDays(1);
response.Cookies.Add(cookie);
}}