不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
为ASP.NET应用程序添加新的文件类型
编辑:dnawo 日期:2011-09-14
在做SP业务时经常会涉及到mo和mr同步,我就想用如下格式url做为同步地址,直观并且不易出错:
要做到这样其实也很简单,只需将原本的.aspx页面扩展名改为.mo或.mr,并且在IIS中添加相应的应用程序扩展即可:
但这样出现的问题是在vs中修改文件不方便,下边我们利用IHttpHandler实现ASP.NET URL重写的方法来实现。
为ASP.NET应用程序添加新的文件类型
1.编写一个IHttpHandler实现类
2.配置web.config
3.在IIS中为站点添加应用程序扩展[1]
4.效果预览:
补充说明
[1].因为.mo和.mr文件实际是不存在的,所以添加应用程序扩展时一定不能钩选"确认文件是否存在",否则将返回404,可以留意看下.aspx的应用程序扩展,也是一样没有钩选,这个细节一定要注意!
引用内容
mo同步:http://127.0.0.1/10001.mo
mr同步:http://127.0.0.1/10001.mr
mr同步:http://127.0.0.1/10001.mr
要做到这样其实也很简单,只需将原本的.aspx页面扩展名改为.mo或.mr,并且在IIS中添加相应的应用程序扩展即可:
引用内容
.mo C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
.mr C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
.mr C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
但这样出现的问题是在vs中修改文件不方便,下边我们利用IHttpHandler实现ASP.NET URL重写的方法来实现。
为ASP.NET应用程序添加新的文件类型
1.编写一个IHttpHandler实现类
复制内容到剪贴板 程序代码
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web;
/// <summary>
///OwnHttpHandler 的摘要说明
/// </summary>
public class OwnHttpHandler : IHttpHandler
{
#region IHttpHandler 成员
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
Match match;
match = Regex.Match(context.Request.Path, @"^/(\w+)\.mo", RegexOptions.IgnoreCase);
if (match.Success)
{
context.Response.Write("mo同步成功!");
}
else
{
match = Regex.Match(context.Request.Path, @"^/(\w+)\.mr", RegexOptions.IgnoreCase);
if (match.Success)
{
context.Response.Write("mr同步成功!");
}
else
{
context.Response.Write("未知同步类型!");
}
}
}
#endregion
}
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web;
/// <summary>
///OwnHttpHandler 的摘要说明
/// </summary>
public class OwnHttpHandler : IHttpHandler
{
#region IHttpHandler 成员
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
Match match;
match = Regex.Match(context.Request.Path, @"^/(\w+)\.mo", RegexOptions.IgnoreCase);
if (match.Success)
{
context.Response.Write("mo同步成功!");
}
else
{
match = Regex.Match(context.Request.Path, @"^/(\w+)\.mr", RegexOptions.IgnoreCase);
if (match.Success)
{
context.Response.Write("mr同步成功!");
}
else
{
context.Response.Write("未知同步类型!");
}
}
}
#endregion
}
2.配置web.config
复制内容到剪贴板 程序代码
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="false" />
<authentication mode="Windows" />
<httpHandlers>
<add verb="*" path="/*.mo" type="OwnHttpHandler" />
<add verb="*" path="/*.mr" type="OwnHttpHandler" />
</httpHandlers>
</system.web>
</configuration>
<configuration>
<system.web>
<compilation debug="false" />
<authentication mode="Windows" />
<httpHandlers>
<add verb="*" path="/*.mo" type="OwnHttpHandler" />
<add verb="*" path="/*.mr" type="OwnHttpHandler" />
</httpHandlers>
</system.web>
</configuration>
3.在IIS中为站点添加应用程序扩展[1]
4.效果预览:
补充说明
[1].因为.mo和.mr文件实际是不存在的,所以添加应用程序扩展时一定不能钩选"确认文件是否存在",否则将返回404,可以留意看下.aspx的应用程序扩展,也是一样没有钩选,这个细节一定要注意!
上一篇: MSSQL2005:sum or average aggregate运算不能以bit数据类型作为参数
下一篇: 设置Serv-U允许匿名下载
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
最新日志:
下一篇: 设置Serv-U允许匿名下载
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
最新日志:
评论: 0 | 引用: 0 | 查看次数: 3420
发表评论
请登录后再发表评论!