色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

asp.net url重寫淺談

ActionlessForm.dll------用來(lái)處理回發(fā)
URLRewriter.dll----- 是微軟封裝好了的一個(gè)URL重寫組件
添加引用----
具體的使用說(shuō)明請(qǐng)去看
http://msdn.microsoft.com/zh-cn/library/ms972974.ASPx#XSLTsection123121120120
比我說(shuō)得好得多。。
具體使用方法:
首先web.config的配置:
復(fù)制代碼 代碼如下:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler,
URLRewriter" />
</configSections>
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/ListCategories/.ASPx</LookFor>
<SendTo>~/Default.ASPx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/(/d+)/.html</LookFor>
<SendTo>~/Cover.ASPx?id=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<system.web>
<httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>
</httpModules>
<compilation debug="true"/>
</system.web>
</configuration>

主要配置的代碼是這些。其他的根據(jù)自己的需要和.NET的版本自行添加。
然后Default.ASPx,Cover.ASPx,新建2個(gè)頁(yè)面
Default.ASPx:
復(fù)制代碼 代碼如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.ASPx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>無(wú)標(biāo)題頁(yè)</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="ListCategories.ASPx">ListCategories.ASPx</a>
<a href="30.html">30.html</a>
</div>
</form>
</body>
</html>

Cover.ASPx:
復(fù)制代碼 代碼如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Cover.ASPx.cs" Inherits="Cover" %>
<%@ Register TagPrefix="skm" Namespace="ActionlessForm" Assembly="ActionlessForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Cover</title>
</head>
<body>
<skm:form id="form1" runat="server">
<div>
Cover頁(yè)面
<h4><a href="Javascript:void(0)" onclick="history.go(-1)">返回</a></h4>
<ASP:Button ID="Button1" runat="server" Text="Button" />
</div>
</skm:form>
</body>
</html>

Cover.ASPx.cs:
復(fù)制代碼 代碼如下:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Cover : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] == null)
{
Response.End();
}
else
{
int id = Convert.ToInt32(Request.QueryString["id"]);
Response.Write(id);
}
}
}

還要去對(duì)iis設(shè)置:

這樣的話偽靜態(tài)就可以用了
C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/ASPNET_isapi.dll ---這是上面的路徑

瀏覽Default.ASPx頁(yè)

ListCategories.ASPx --頁(yè)面其實(shí)在服務(wù)器上面是沒有的。它里面的內(nèi)容是Default.ASPx的內(nèi)容,因?yàn)榕渲梦募锩嬖O(shè)置了

寫得有點(diǎn)亂。

本例子是和微軟的重寫url基本一樣的。算是簡(jiǎn)單化了一點(diǎn)點(diǎn)呵呵。

AspNet技術(shù)asp.net url重寫淺談,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 长沙县| 来安县| 泗阳县| 太仓市| 辽中县| 郑州市| 天等县| 建始县| 黔西县| 临安市| 唐海县| 高台县| 晴隆县| 界首市| 延安市| 平利县| 桓台县| 金沙县| 东乌珠穆沁旗| 资中县| 呼和浩特市| 郑州市| 札达县| 通榆县| 宕昌县| 吉木萨尔县| 辛集市| 监利县| 金寨县| 丹巴县| 德格县| 商丘市| 黔江区| 阜宁县| 固安县| 贵阳市| 建湖县| 大新县| 类乌齐县| 瑞金市| 鹤山市|