平文の古いASP.NETでCookieを読み取るのは、HttpContext.Current.Request
オブジェクトを取得するのと同じくらい簡単ですが、DNXではそのようなオブジェクトはありません。Microsoft.AspNet(DNX)でCookieを読み取る方法
応答を変更するには、Cookie値をどのようにチェックするのですか?
public static string GetContentValueByKey(this Dictionary<string, string> content, string key) {
string value;
var cookies = HttpContext.Current.Request.Cookies;
var showKeysOnly = cookies["showonlykeys"] != null && cookies["showonlykeys"] == "yes";
return showKeysOnly ? key : content.TryGetValue(key, out value) ? value : key;
}
が、私たちはもはや:
public static string GetContentValueByKey(this Dictionary<string, string> content, string key) {
string value;
return content.TryGetValue(key, out value) ? value : key;
}
は私が返すのみkey
代わりvalue
...私は簡単に行うことができ、「古き良き日」で、クッキーの値に基づいて、今たくありませんそのようなオブジェクトにアクセスできます...コントローラの外部にあるCookieにアクセスするためのトリックは何ですか?
ps。 DNXは古くなっており、もはやサポートされていません。 RTMに更新! – Thomas