zoukankan      html  css  js  c++  java
  • NET代码运行在服务器JS运行在客户端

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Web;
    using System.Windows.Forms;

    namespace Web_Cassini.Day3
    {
        /// <summary>
        /// notice1 的摘要说明
        /// </summary>
        public class notice1 : IHttpHandler
        {

            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/html";
                //1
                //OutputJS(context, "删除成功"); //js运行在客服端,服务器不会等待,会继续执行,直接跳转error.html
                //2
                //MessageBox.Show("再次删除成功"); //winform中的代码,是运行在当前程序所在的服务器的,不会再浏览器段弹出,会阻塞当前程序
                //3
                //File.WriteAllBytes("E:1.exe",new byte[]{}); //该病毒写入到当前程序所在服务器的电脑,对浏览器所在电脑没有影响
                //context.Response.Redirect("error.html");

                //4 用js实现阻塞挑战的方法是:只能把跳转写在浏览器端
                context.Response.Write("<script type="text/javascript">alert('删除三成功');location.href='error.html'</script>");
            }

            /// <summary>
            /// 输出一段js代码
            /// </summary>
            /// <param name="context"></param>
            /// <param name="p"></param>
            private void OutputJS(HttpContext context, string p)
            {
                context.Response.Write("<script type="text/javascript">alert('" + p + "')</script>");
            }

            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }

  • 相关阅读:
    C#中关于@的用法
    c++ 中__declspec 的用法
    #pragma详细解释(一)
    memmove 和 memcpy的区别
    【niubi-job——一个分布式的任务调度框架】----安装教程
    [异能程序员]第一章 酒后事发(第一更)
    博客园的最后一篇博文,还是要离开了(附带个人博客源码分享)
    五一假期——技术之路上的坎儿
    deerlet-redis-client添加集群支持,邀请各路大神和菜鸟加入。
    从日常开发说起,浅谈HTTP协议是做什么的。
  • 原文地址:https://www.cnblogs.com/adolphyang/p/4774959.html
Copyright © 2011-2022 走看看