妙用HttpHandler

通用 万能 HttpHandler webRequest 文件上传 通用的HttpHandler 万能的HttpHandler HttpwebRequest文件上传 立即下载

很多时候,我们新建一个xxx.aspx页和xxx.aspx.cs文件,不过是为了实现一个很简单的功能,如:输出xmlDom,注销并跳转,并没有什么html的输出,很是麻烦,需要新建一个页,删除多余的html,并在page_load里面写处理代码。而使用HttpHandler就不需要这么麻烦了。

可以用任何符合公共语言规范 (CLS) 的语言编写自定义 HTTP 处理程序来处理特定的、预定义类型的 HTTP 请求。响应这些特定请求的是在 HttpHandler 类中定义的可执行代码,而不是常规的 ASP 或 ASP.NET Web 页。HTTP 处理程序向您提供一种方法,使您可以与 IIS Web 服务器的低级别的请求和响应服务交互,同时提供极其类似于 ISAPI 扩展但编程模型较为简单的功能。

例如我现在需要实现一个注销并跳转的Logout.aspx页面,下面的示例主要实现了响应客户端对名为 logout.aspx 的页的请求,实现注销并跳转。对 logout.aspx 的所有请求均由包含在程序集 WebUC.dll 中的命名空间 WebUC.HttpHandler 中的 LogoutHttpHandler 提供服务。

修改web.config,在<system.web></system.web>中增加如下脚本:
<httpHandlers>
 <add verb="GET" path="Logout.aspx" type="WebUC.HttpHandler.LogoutHttpHandler, WebUC" />
</httpHandlers>
其中WebUC.HttpHandler.LogoutHttpHandler是我要实现Logout.aspx功能的类,WebUC是我web项目的dll。(具体介绍可以参阅msdn)

下面是LogoutHttpHandler的代码,继承借口,重写方法和属性。

using System;
using System.Web;
using System.Web.Caching;
using System.Web.Security;

namespace WebUC.HttpHandler
{

 public class LogoutHttpHandler : IHttpHandler
 {
  /// <summary>
  /// 通过实现 IHttpHandler 接口的自定义 HttpHandler 启用 HTTP Web 请求的处理。
  /// </summary>
  /// <param name="context">HttpContext 对象,它提供对用于为 HTTP 请求提供服务的内部服务器对象(如 Request、Response、Session 和 Server)的引用。 </param>
  public void ProcessRequest (HttpContext context)
  {
   FormsAuthentication.SignOut();
   context.Response.Redirect("Login.aspx",true);
  }

  /// <summary>
  /// 获取一个值,该值指示其他请求是否可以使用 IHttpHandler 实例。
  /// </summary>

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

编译后,我就可以直接使用http://***/logout.aspx 来实现注销了,而实际上,我的web目录下并没有logout.aspx这个文件,同样,这个技巧可以用在很多方面,例如防止盗链,下载统计等。

来源:http://webuc.net/dotey/archive/2004/06/08/966.aspx

基于Labview2012实现的双通道信号源(课程设计) 双通道信号源,产生8种波形,能进行调制,带信号幅度与频率扫描功能,波形可存储与导入 阅读详情

相关推荐

毫米波与太赫兹:十射线模型建模

Pt=1,只考虑地面和前后两面墙的反射,反射系数为0.7。用matlab设计程序并实现该功能。,总计考虑10条路径,求出接收功率随。

SupermarketX的博客 785

妙用Asp.Net中的HttpHandler[转]

很多时候,我们新建一个xxx.aspx页和xxx.aspx.cs文件,不过是为了实现一个很简单的功能,如:输出xmlDom,注销并跳转,并没有什么html的输出,很是麻烦,需要新建一个页,删除多余的html,并在page_load里面写处理代码。而使用HttpHandler就不需要这么麻烦了。可以用任何符合公共语言规范 (CLS) 的语言编写自定义 HTTP 处理程序来处理特定的、预定义类型的 H

1204

别再傻傻分不清!Synopsys DC综合中link/target/symbol/synthetic四大库的保姆级配置指南

本文详细解析了Synopsys DC综合中link_library、target_library、symbol_library和synthetic_library四大库的配置方法,帮助工程师避免常见错误。通过实战示例和调试技巧,指导如何正确设置工艺库与IP库,提升数字芯片设计效率。

weixin_42562079的博客 423

HTTP必知必会——常见面试题总结

1、常用的HTTP方法有哪些? GET: 用于请求访问已经被URI(统一资源标识符)识别的资源,可以通过URL传参给服务器 POST: 用于传输信息给服务器,主要功能与GET方法类似,但一般推荐使用POST方式。 PUT: 传输文件,报文主体中包含文件内容,保存到对应URI位置。 HEAD: 获得报文首部,与GET方法类似,只是不返回报文主体,一般用于验证URI是否有效。 DELETE

Leeon的博客 6万+

Unity 佳能SDK 及数据获取

3. 把CameraControl 下面只要是绿色的 .cs 文件都复制到Unity 中。1. 填写信息跟官方申请SDK,大概1-2个工作日会邮件回复你。2. 将SDK这两个文件放到 Unity Plugins文件夹。

我知道你很急,但是路要一步步走 1477

华为OD机考双机位C卷 - 风险投资计划(Java & Python& JS & C/C++ & GO )

华为OD机考双机位C卷 - 风险投资计划(OD上机考试双机位C卷)。提供Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。

算法大师! 547

ASP.NET 高级编程基础第十篇—HttpHandler处理

前言:好几天没有写博客了,今天继续写我们的asp.net高级编程基础系列的第十篇,Httphandler处理,通过这篇博客我们可以了解到Httphandler是个干什么的了,当然本来想写写这个底层的,但是想想我们可以自己查一下,所以就没有写了,希望我们能够共同进步。 HttpHandler处理 (1) HttpHandler是对请求的响应,可以输出普通的Html内容,也可以输出图片,也...

weixin_33852020的博客 197

Raspberry Pi Pico SDK开发-Timer-定时

RP2040 由 Raspberry Pi 设计,具有双核 Arm Cortex-M0+ 处理器和 264KB 内部 RAM,并支持高达 16MB 的片外闪存。 广泛的灵活 I/O 选项包括 I2C、SPI 和独特的可编程 I/O (PIO)。 本实例将演示如何使用Timer的定时功能。

视觉与物联智能 2041

ASP.Net中自定义Http处理及应用之HttpHandler篇(转自:http://7880.com/Info/Article-2b783c20.html)

<br /><br />下文主要解决如下问题:<br />当你使用ASP.NET开发网站时,用IHttpHandler处理AJAX请求,然后再Web.config里配置好了访问路径,而且恰好你配置的访问路径的后缀比较诡异,如.c或.cpp或.cs或.123456或.abc等,然后在VS里调试AJAX正常,但是当你把网站放到IIS上后,你会发现你在AJAX中访问的页面不存在,也就是说用IHttpHandler处理AJAX的情况下,在VS里调试正常,但发布到IIS上后就无法进行AJAX。<br /> <br /

lslxdx的专栏 1061

Camunda 7.x 系列【67】实战篇之撤销流程

撤销流程 即撤销当前已发起的流程实例。这是一个常见的需求,Camunda本身不提供直接的方法来撤销正在执行的流程,需要自定义处理逻辑。

记录知识、锤炼自我 1378

【第07例】IPD体系进阶: 6 个技术评审点(TR)

TR技术评审点

产品线负责人 4419

06 configHandler 全局处理器

public void configHandler(Handlers handlers) { // JFinal配置处理器 //伪静态,默认后缀HTML //handlers.add(new FakeStaticHandler()); handlers.add(new LogHandler()); } //========...

BlossomWave的博客 506

R语言 百度坐标转换至WGS84坐标

本文利用R语言封装了百度坐标转换至WGS84坐标的函数,亲测有效,提供了便捷的百度坐标转换方法。

qingchen98的博客 2135

妙用Asp.Net中的HttpHandler

妙用Asp.Net中的HttpHandler 很多时候,我们新建一个xxx.aspx页和xxx.aspx.cs文件,不过是为了实现一个很简单的功能,如:输出xmlDom,注销并跳转,并没有什么html的输出,很是麻烦,需要新建一个页,删除多余的html,并在page_load里面写处理代码。而使用HttpHandler就不需要这么麻烦了。可以用任何符合公共语言规范 (CLS) 的语言编写自

NiuNIu's sPAcE 2407

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

上一篇: 使用Response.Redirect时忽略异常ThreadAbortException
下一篇: 利用消息机制实现.NET AOP(面向方面编程)--通过RealProxy实现 zz
libraworm
博客等级 码龄24年 3粉丝 24原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值