<!--web.config-->
<?xml version="1.0"?>
<!--
注意: 除了手动编辑此文件以外,您还可以使用
Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
“网站”->“Asp.Net 配置”选项。
设置和注释的完整列表在
machine.config.comments 中,该文件通常位于
\Windows\Microsoft.Net\Framework\v2.x\Config 中
-->
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
设置 compilation debug="true" 可将调试符号插入
已编译的页面中。但由于这会
影响性能,因此只在开发过程中将此值
设置为 true。
-->
<compilation debug="true">
</compilation>
<!--
通过 <authentication> 节可以配置 ASP.NET 用来
识别进入用户的
安全身份验证模式。
-->
<authentication mode="Windows"/>
<!--
如果在执行请求的过程中出现未处理的错误,
则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
开发人员通过该节可以配置
要显示的 html 错误页
以代替错误堆栈跟踪。
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<!--这部分为实际作用区域-->
<httpModules>
<add name="ModuleTest" type="TestHttpModule"/>
</httpModules>
<!--这部分为实际作用区域结束-->
</system.web>
</configuration>
//添加类代码
using System;
using System.Collections.Generic;
using System.Web;
using System.Text.RegularExpressions;
/// <summary>
/// 此一类的使用要配合在Web.Config中配置如下内容(<system.web>节点内)
///<httpModules>
/// <add name="ModuleTest" type="TestHttpModule"/>
///</httpModules>
/// </summary>
public class TestHttpModule:IHttpModule
{
void IHttpModule.Dispose()
{
//throw new NotImplementedException();
}
void IHttpModule.Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(FunMethod); //注册方法
}
private void FunMethod(object sender, EventArgs e) //处理
{
HttpApplication application = (HttpApplication)sender;
HttpContext context = application.Context;
HttpRequest request = application.Request;
HttpResponse response = application.Response;
//response.Write("可以直接输出内容");
string _url = request.Url.ToString();
//匹配跳转
if (Regex.IsMatch(_url, "^http://localhost:10000/httpModulesTest/\\d+", RegexOptions.IgnoreCase))
{
Regex reg = new Regex("^http://localhost:10000/httpModulesTest/(\\d+)", RegexOptions.IgnoreCase);
Match m = reg.Match(_url);
if (m.Success)
{
string mId = m.Groups[1].ToString();
response.Redirect("http://www.baidu.com?id=" + mId);
}
}
}
}
原码:
http://dl.iteye.com/topics/download/c5335581-d822-3210-9497-b7720f68bd0d
分享到:
相关推荐
httpModules方式伪静态 -----C#.Net实例代码
协诚HTTP在线解压组件_sycode.httpmodules.webcompression
[上传下载]协诚HTTP在线解压组件_sycode.httpmodules.webcompression.zip源码ASP.NE[上传下载]协诚HTTP在线解压组件_sycode.httpmodules.webcompression.zip源码ASP.NE[上传下载]协诚HTTP在线解压组件_sycode....
HTTPModules入门篇[借鉴].pdf
利用httpModules实现防SQL注入
ASP.NET-[上传下载]协诚HTTP在线解压组件.httpmodules.webcompression.zip
引言,从ASP迁移到ASP.NET,页框架,调试ASP.NET应用程序,状态控制和缓存,配置和部署,Web服务,安全,HttpHandlers和HttpModules,创建用户控件和服务器控件,使用XML以及使用ADO.NET创建数据库应用程序等。...
ASP.NET 2.0通用防注入插件源代码 利用了httpModules对字符进行检测,仅仅对少数几个关键SQL命令进行了检测。 跳过了multipart/form-data类型的数据。 即插即用型 :)放置如bin目录。修改web.config即可。...
Add to the httpModules section inside system.web (if httpModules section does not exist, create it) <httpModules> , blowery.web.HttpCompress"/> </httpModules> Add to the configuration section ...
一个通过HTTP modules模式在runtime 运行时创建服务端Web控件的源码例子
<httpModules>, Core.Net" name="URLHttpHandle"/></httpModules> 如果想转换其它伪页面,方法如下: 在appSettings节点下加 key="postfix",value值为要转换的格式 如:value="php" 还有其它好多asp.net网站开发...
通用的文件上传工具,包括上传进度条.文件大小显示等等,而且可直接使用.通过控件+fileupload自带控件实现普通文件上传及其超大文件上传. 请不要忘记更改web.config中的: ... </httpModules>
引言,从ASP迁移到ASP.NET,页框架,调试ASP.NET应用程序,状态控制和缓存,配置和部署,Web服务,安全,HttpHandlers和HttpModules,创建用户控件和服务器控件,使用XML以及使用ADO.NET创建数据库应用程序等。
<httpModules> , MagicAjax" /> </httpModules> 在希望采用Ajax的webForm页面HTML开头引入Ajax的注册语句: <%@ Register TagPrefix="ajax" Namespace="MagicAjax.UI.Controls" Assembly="MagicAjax" %>
暑假,终于下定决定要启用win2008了,经过上面的破解、配置,iis终于装好了。把博客程序考到机器上,摸索着进行配置...<httpModules>”ModuleRewriter” type=”URLRewriter.ModuleRewriter,></httpModules>这是后来发
MagicAjax.dll
所有ASP.NET Core应用程序至少需要一个中间件来响应请求,并且您的应用程序实际上只是中间件的集合。当然MVC管道本身就是中间件,早在WebForm时代就出现过HttpModules、HttpHandler、那个时候悠然记得我通过它们来...
<httpModules> type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" name="UrlRewriter" /> </httpModules> This enables the URL Rewriter to intercept web ...
PerformanceMonitor 模块 地位 托管代码HttpModule ... C#HttpModule是托管代码并在常规.NET CLR中执行,这一事实意味着它处理应用程序域( ),这是一个提高安全性和可靠性的应用程序隔离容器。