当前位置: 首页>>代码示例>>C#>>正文


C# OSHttpResponse.AddCookie方法代码示例

本文整理汇总了C#中Aurora.Framework.Servers.HttpServer.OSHttpResponse.AddCookie方法的典型用法代码示例。如果您正苦于以下问题:C# OSHttpResponse.AddCookie方法的具体用法?C# OSHttpResponse.AddCookie怎么用?C# OSHttpResponse.AddCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Aurora.Framework.Servers.HttpServer.OSHttpResponse的用法示例。


在下文中一共展示了OSHttpResponse.AddCookie方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Fill

        public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
            OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary<string, object>();

            string error = "";
            if (requestParameters.ContainsKey("username") && requestParameters.ContainsKey("password"))
            {
                string username = requestParameters["username"].ToString();
                string password = requestParameters["password"].ToString();

                ILoginService loginService = webInterface.Registry.RequestModuleInterface<ILoginService>();
                if (loginService.VerifyClient(UUID.Zero, username, "UserAccount", password))
                {
                    UUID sessionID = UUID.Random();
                    UserAccount account = webInterface.Registry.RequestModuleInterface<IUserAccountService>().GetUserAccount(null, username);
                    Authenticator.AddAuthentication(sessionID, account);
                    if (account.UserLevel > 0)
                        Authenticator.AddAdminAuthentication(sessionID, account);
                    httpResponse.AddCookie(new System.Web.HttpCookie("SessionID", sessionID.ToString()) { Expires = DateTime.MinValue, Path = "" });

                    response = "<h3>Successfully logged in, redirecting to main page</h3>" +
                        "<script language=\"javascript\">" +
                        "setTimeout(function() {window.location.href = \"index.html\";}, 0);" +
                        "</script>";
                }
                else
                    response = "<h3>Failed to verify user name and password</h3>";
                return null;
            }

            vars.Add("ErrorMessage", error);
            vars.Add("Login", translator.GetTranslatedString("Login"));
            vars.Add("UserNameText", translator.GetTranslatedString("UserName"));
            vars.Add("PasswordText", translator.GetTranslatedString("Password"));
            vars.Add("ForgotPassword", translator.GetTranslatedString("ForgotPassword"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));

            return vars;
        }
开发者ID:rjspence,项目名称:YourSim,代码行数:41,代码来源:login.cs

示例2: Fill

        public Dictionary<string, object> Fill(WebInterface webInterface, string filename, Hashtable query, OSHttpResponse httpResponse,
            Dictionary<string, object> requestParameters, ITranslator translator)
        {
            var vars = new Dictionary<string, object>();

            string error = "";
            if (requestParameters.ContainsKey("username") && requestParameters.ContainsKey("password"))
            {
                string username = requestParameters["username"].ToString();
                string password = requestParameters["password"].ToString();

                ILoginService loginService = webInterface.Registry.RequestModuleInterface<ILoginService>();
                if (loginService.VerifyClient(UUID.Zero, username, "UserAccount", password, UUID.Zero))
                {
                    UUID sessionID = UUID.Random();
                    UserAccount account = webInterface.Registry.RequestModuleInterface<IUserAccountService>().GetUserAccount(UUID.Zero, username);
                    Authenticator.AddAuthentication(sessionID, account.PrincipalID);
                    if (account.UserLevel > 0)
                        Authenticator.AddAdminAuthentication(sessionID, account.PrincipalID);
                    httpResponse.AddCookie(new System.Web.HttpCookie("SessionID", sessionID.ToString()) { Expires = DateTime.MinValue, Path = "" });

                    httpResponse.StatusCode = (int)HttpStatusCode.Redirect;
                    httpResponse.AddHeader("Location", "/welcomescreen/index.html");

                    return vars;
                }
                else
                    error = "Failed to verify user name and password";
            }

            vars.Add("ErrorMessage", error);
            vars.Add("Login", translator.GetTranslatedString("Login"));
            vars.Add("UserNameText", translator.GetTranslatedString("UserName"));
            vars.Add("PasswordText", translator.GetTranslatedString("Password"));
            vars.Add("ForgotPassword", translator.GetTranslatedString("ForgotPassword"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));

            return vars;
        }
开发者ID:JAllard,项目名称:Aurora-Sim,代码行数:39,代码来源:login.cs

示例3: AddVarsForPage

        protected Dictionary<string, object> AddVarsForPage(string filename, string parentFileName, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, out string response)
        {
            response = null;
            Dictionary<string, object> vars = new Dictionary<string, object>();
            IWebInterfacePage page = GetPage(filename);
            if (page != null)
            {
                ITranslator translator = null;
                if (httpRequest.Query.ContainsKey("language"))
                {
                    translator = _translators.FirstOrDefault(t => t.LanguageName == httpRequest.Query["language"].ToString());
                    httpResponse.AddCookie(new System.Web.HttpCookie("language", httpRequest.Query["language"].ToString()));
                }
                else if (httpRequest.Cookies.Get("language") != null)
                {
                    var cookie = httpRequest.Cookies.Get("language");
                    translator = _translators.FirstOrDefault(t => t.LanguageName == cookie.Value);
                }
                if (translator == null)
                    translator = _defaultTranslator;

                if (page.RequiresAuthentication)
                {
                    if (!Authenticator.CheckAuthentication(httpRequest))
                        return null;
                }
                if (page.RequiresAdminAuthentication)
                {
                    if (!Authenticator.CheckAdminAuthentication(httpRequest))
                        return null;
                }
                vars = page.Fill(this, parentFileName, httpRequest, httpResponse, requestParameters, translator, out response);
                return vars;
            }
            return null;
        }
开发者ID:rjspence,项目名称:YourSim,代码行数:36,代码来源:WebInterface.cs


注:本文中的Aurora.Framework.Servers.HttpServer.OSHttpResponse.AddCookie方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。