Exemplo n.º 1
0
        /// <summary>
        /// Inserts a hidden form input with a generated token.
        /// <para>Validate using <see cref="ValidateSessionTokenAttribute"/>.</para>
        /// </summary>
        public static MvcHtmlString AddValidateSessionTokenField(this HtmlHelper html)
        {
            var name  = ValidateSessionTokenAttribute._formInputName;
            var token = ValidateSessionTokenAttribute.CreateNewToken();

            var content = $"<input name=\"{name}\" type=\"hidden\" value=\"{token}\" />";

            return(new MvcHtmlString(content));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retuns a generated token.
        /// <para>Validate using <see cref="ValidateSessionTokenAttribute"/>.</para>
        /// </summary>
        public static MvcHtmlString GetNewValidateSessionToken(this HtmlHelper html)
        {
            var token = ValidateSessionTokenAttribute.CreateNewToken();

            return(new MvcHtmlString(token));
        }