本文介绍了无法使用[]将索引应用于类型为“System.Collections.Specialized.NameValueCollection”的表达式,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试了太阳下的所有东西,以访问AppSettings,我无法让它工作。
I've tried everything under the sun to get access to the AppSettings and I cannot get this to work.
我有一个类库需要访问到web AppSettings。我检查过,没有
'System.Collections.Specialized.NameValueCollection'可以导入。
I've got a class library that needs access to the web AppSettings. I've checked and there is no'System.Collections.Specialized.NameValueCollection' to import.
任何人都有任何想法?
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);
}}
推荐答案
我添加了对System 4.0的引用,一切。
I added a reference to System 4.0 and that fixed everything .
这篇关于无法使用[]将索引应用于类型为“System.Collections.Specialized.NameValueCollection”的表达式,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!