^(\+98|0)?9\d{9}$
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Post | |
{ | |
public string Title { get; set; } | |
[AllowHtml] | |
[UIHint("tinymce_jquery_full")] | |
public string Description { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PostsController : Controller | |
{ | |
public ActionResult Create() | |
{ | |
return View(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model TinyMCE.Models.Post | |
@{ | |
ViewBag.Title = "Create"; | |
} | |
<h2>Create</h2> | |
@using (Html.BeginForm()) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model TinyMCE.Models.Post | |
<h2>Details</h2> | |
@Html.Raw(Model.Description) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class SiteSettings | |
{ | |
public const string GoogleRecaptchaSecretKey = "6Lea1EYUAAAAACn3pDs7EL8msJh0h0KgH-ajakZ_"; | |
public const string GoogleRecaptchaSiteKey = "6Lea1EYUAAAAAHvvT5xIFXt1UknyKUf1C1w5Ko77"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class GoogleCaptchaHelper | |
{ | |
public static IHtmlString GoogleCaptcha(this HtmlHelper helper) | |
{ | |
const string publicSiteKey = SiteSettings.GoogleRecaptchaSiteKey; | |
var mvcHtmlString = new TagBuilder("div") | |
{ | |
Attributes = | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class InvalidGoogleCaptchaHelper | |
{ | |
public static IHtmlString InvalidGoogleCaptchaLabel(this HtmlHelper helper, string errorText) | |
{ | |
var invalidCaptchaObj = helper.ViewContext.Controller.TempData["InvalidCaptcha"]; | |
var invalidCaptcha = invalidCaptchaObj?.ToString(); | |
if (string.IsNullOrWhiteSpace(invalidCaptcha)) return MvcHtmlString.Create(""); | |
var buttonTag = new TagBuilder("span") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValidateGoogleCaptchaAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(ActionExecutingContext filterContext) | |
{ | |
const string urlToPost = "https://www.google.com/recaptcha/api/siteverify"; | |
const string secretKey = SiteSettings.GoogleRecaptchaSecretKey; | |
var captchaResponse = filterContext.HttpContext.Request.Form["g-recaptcha-response"]; | |
if (string.IsNullOrWhiteSpace(captchaResponse)) AddErrorAndRedirectToGetAction(filterContext); |
OlderNewer