Ich habe ein ziemlich kompliziertes Projekt geerbt. Der ursprüngliche Designer hat einen "Cookie" erstellt, der eher serverseitig als clientbasiert zu sein scheint (obwohl ich in diesem Teil sehr falsch liegen könnte). Er benutzt es für das, was er "Least Privileges, Single Sign On" nannte. Ich habe den folgenden Code in all den Web-Service-Proxies gründete er:Server Cookies?
[WebServiceBinding(Name = "ISecurityManager", Namespace = "urn:riv:apis:security:forms:ver1")]
public partial class SecurityManager : SoapHttpClientProtocol, ISecurityManager
{
public SecurityManager()
{
//Url = CookieManager.WebServiceUrl(String.Empty, ref CookieContainer);
// I’d like to replace the following code with a call like this...
CookieContainer = new System.Net.CookieContainer();
string urlSetting = ConfigurationManager.AppSettings["SecurityManager"];
if (urlSetting != null)
Url = urlSetting;
else
Trace.TraceWarning("No URL was found in application configuration file");
string cookieName = FormsAuthentication.FormsCookieName;
string cookiePath = FormsAuthentication.FormsCookiePath;
string cookieDomain = Properties.Settings.Default.CookieDomain;
HttpCookie authCookie = HttpContext.Current.Request.Cookies[cookieName];
if (null != authCookie)
CookieContainer.Add(new Uri(urlSetting), new System.Net.Cookie(cookieName, authCookie.Value, cookiePath, cookieDomain));
}
….
ich auch diesen Code haben ziemlich überall:
string cookieName = FormsAuthentication.FormsCookieName;
string SecurityContext.ApplicationName = HttpContext.Current.Request.Cookies[cookieName].Path;
string SecurityContext.UserName = HttpContext.Current.User.Identity.Name;
if (!string.IsNullOrEmpty(SecurityContext.UserName))
….
In allen Fällen, wenn es geht zu erhalten der authCookie, es kommt Null oder der SecurityContext.UserName ist leer. Ich bin kein Cookie-Guru und viel Code dieses Kerls ist verschleiert - und keine Dokumentation.
Kann jemand Kopf oder Zahl aus der Absicht der Codeblöcke machen?
TIA