利用URL重写隐藏复杂的URL

来源:互联网 发布:c语言跑马灯程序 编辑:程序博客网 时间:2024/04/30 09:59

第一步:模拟映射页面

我们想在一个页面上点击guid.html链接,跳转到比较复杂URL的guid_{492f3e0b-848e-11da-9550-00e08161165f}.html页面。即定义一个映射,该映射隐藏实际的URL并将其映射到用户更容易记忆的URL。

第二步:如何做到呢

来个非常简单的,在web.config文件的system.web节点设置urlMappings。

<system.web>    <urlMappings enabled="True">        <add url="~/guid.html" mappedUrl="guid_{492f3e0b-848e-11da-9550-00e08161165f}.html"/>    </urlMappings></system.web>

这时,点击guid.html链接,地址栏是guid.html,实际上是guid_{492f3e0b-848e-11da-9550-00e08161165f}.html页面的内容了。

原创粉丝点击