NET代码运行在服务器JS运行在客户端
2015-09-01 10:01
459 查看
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;
}
}
}
}
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;
}
}
}
}
相关文章推荐
- js正则表达式 验证手机号,email地址和邮政编码
- js 点击某个区域跳转 即某个<div区域
- json-lib 的maven dependency
- JavaScript常用标签和方法总结
- JavaScript 的AMD
- javascript中内置函数
- JSP中输入框的设置问题
- js控制html控件显示隐藏和是否可用
- JS中typeof与instanceof的区别
- JSTL详解
- JavaScript中innerHTML,innerText,outerHTML的用法及区别
- JSON数据解析
- Js 时间间隔计算(间隔天数)
- js获取某元素的class里面的css属性值代码(转)
- JavaScript中知而不全的this
- JavaScript学习笔记之CSS-DOM
- JavaScript学习笔记3-JavaScript中的继承
- Js 代替eval的方法
- web-javascript出现的全局变量的问题(*)
- JSP - Custom Tags