在运行时progmatically RewriteMap指令规则 [英] progmatically rewritemap rules at runtime
问题描述
是否可以添加静态rewritemaps规则progmatically为ASP.NET 3.5
Is it possible to add static rewritemaps rules progmatically for ASP.NET 3.5
我有: -
<rewriteMaps>
<rewriteMap name="My Name">
<add key="/Sales" value="/Test.aspx?id=10" />
<add key="/Sales-And-Marketing" value="/Test.aspx?id=10&dog=cat" />
</rewriteMap>
</rewriteMaps>
但想添加这些progmatically在运行时?
but would like to add these progmatically at runtime?
推荐答案
它有点晚了,我知道,但你可以通过在一个单独配置的URL做编程
Its a little late I know, but you can do it programmatically by having the url in a seperate config
<rewrite>
<rewriteMaps configSource="urls.config" />
<rules>
<rule name="Rewrite rule1 for StaticRedirect">
<match url=".*" />
<conditions>
<add input="{StaticRedirect:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Rewrite" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
您则需要写当过你的URL变化,我做这个配置文件时有改变,并保存通过CMS管理系统页面,使用web服务跟我们的客户网站,并指示它重建文件中。
You then need to write to this config file when ever your urls change, I do it when there is a page altered and saved through the CMS admin system, using a webservice to talk to the client website and instruct it to rebuild the file.
我唯一的问题是,这似乎不希望在Visual Studio开发Web服务器的工作。
The only issue I have is this doesnt seem to want work in Visual Studio Development Webserver
这篇关于在运行时progmatically RewriteMap指令规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!