ASP.NET URL在非常简单的方法重写 [英] ASP.NET URL Rewriting in very easy way

查看:131
本文介绍了ASP.NET URL在非常简单的方法重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使SEF URL的网页。有点谷歌搜索后,我发现有很多技巧,但他们都非常复杂。我不需要他们。有没有什么办法让海基会的URL,这是非常容易实现的?

I want to know how to make SEF URL for web pages. After a little googling I have found many techniques, but all of them are so complicated. I do not need them. Is there any way to make SEF URL which is very easy to implement?

推荐答案

首先下载这个参考

然后将它导入到你的网站。

Then import it to your web site.

<结构> 节点类型是:

<configSections>
    <section name="urlrewritingnet" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter"/>
</configSections>

下一步是下键入以下code &LT;&的System.Web GT; 节点:
    
            
        

The next step is typing the following code under <system.web> node:

下一个是把下面这行之前&LT; /结构&gt; 标签:

the next one is putting the following line just before </configuration> tag:

<urlrewritingnet configSource="RewriteRules.config"/>

我们几乎完成了!

创建该标签的configResource参数相匹配的新的config文件。我preferredRewriteRules.config。

Create a new .config file which matches the tag's configResource parameter. I preferred "RewriteRules.config".

那么现在是时候来创建RewriteRules.config文件重写规则:

Then it is time to create rewriting rules on RewriteRules.config file:

<urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" defaultPage="Default.aspx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
    <rewrites>
        <add name="DetailPageRule" virtualUrl="^~/VirtualDetailPageName/(.*)/(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/RealDetailPage.aspx?param1=$1&amp;param2=$2" ignoreCase=" true"/>
    </rewrites>
</urlrewritingnet>

如果您有更多或更少的参数,你可以改变的计数()的。这里只有两个参数(参数1和参数),所以只有两个(的)字符串。

If you have more or less parameters you can change the count of (.)'s. Here there are only two parameters (param1 and param2), so there are only two (.) strings.

最后一步是给在根据您所创建的规则的链接。

Final Step is giving links in according to the rules you have created.

这是简单,快捷。但我不知道是否有缺点或任何安全问题。

It is simple and fast. But I do not know if there are drawbacks or any security issues.

这篇关于ASP.NET URL在非常简单的方法重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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