Ejemplo n.º 1
0
        public dynamic Captcha()
        {
            string           fileName = Guid.NewGuid().ToString() + ".bmp";
            string           filePath = HostingEnvronment.GetMapPath("/wwwroot/" + fileName);
            CaptchaImageCore image    = new CaptchaImageCore(220, 60, 57);
            var stream = image.GetStream(filePath);

            this.Session["captchacode"] = image.Text;
            return(new FileResult(filePath, "image/jpg", stream));
        }
Ejemplo n.º 2
0
        public static string LoadTemplateContent(string viewName)
        {
            string templatePath = HostingEnvronment.GetMapPath(viewName);

            if (!File.Exists(templatePath))
            {
                throw new FileNotFoundException("view template file can't find.");
            }

            string viewTemplate = null;

            using (StreamReader reader = new StreamReader(new FileStream(templatePath, FileMode.Open, FileAccess.Read), Encoding.UTF8))
            {
                viewTemplate = reader.ReadToEnd();
            }

            return(viewTemplate);
        }