我想在Web.Confi中使用Asp.net重写Url [英] I want ReWrite Url By Asp.net in Web.Confi

查看:42
本文介绍了我想在Web.Confi中使用Asp.net重写Url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过Web中的Asp.net重新编写Url。示例更改此URL:http:// localhost:33862 / User / DetailAgahy?Id = 148 To Url:http:// localhost:33862 / User / DetailAgahy / Id / 148

I want ReWrite Url By Asp.net in Web.Config For Example change This Url : http://localhost:33862/User/DetailAgahy?Id=148 To Url : http://localhost:33862/User/DetailAgahy/Id/148

推荐答案

您好。



您应该使用urlrewritingnet, UrlRewritingNet.UrlRewrite 工具。它允许从这样的请求重定向:http://www.windevpowertools.com/ToolPage.aspx?ToolID = 12到此http://www.windevpowertools.com/Tools/12,反之亦然。此工具使用正则表达式从原始请求的URL中捕获ID或其他参数,并将其路径指向真实服务器URL。

例如,这是规则:

Hello.

You should use urlrewritingnet, UrlRewritingNet.UrlRewrite tool. It allows to redirect from request like this: http://www.windevpowertools.com/ToolPage.aspx?ToolID=12 to this http://www.windevpowertools.com/Tools/12 , and vise - versa. This tool is using regular expression to catch up an ID or other parameter from original, requested URL and path it to real server URL.
For example, this is the rule:
<add virtualurl="~/User/DetailAgahy?Id=(\d+)">
    destinationUrl="~/User/DetailAgahy/Id/


1
ignoreCase =true/> < / add >





(\d +) - 将数字值带入params集合,稍后您可以将其引用为



(\d+) - is taking number value into params collection, later you can reference it as


1

因此,在每个地方,你在原始网址中有数字(ID),你指定这个(\d +)并且您可以通过这种方式在目标网址中引用它
1.
So in each place, where you have numbers (IDs) in the original URL, you specify this (\d+) and than you can reference it in the destination URL this way


这篇关于我想在Web.Confi中使用Asp.net重写Url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆