简体   繁体   中英

Use IIS Outbound Rewrites in C# or VB.net

Using IIS URL Rewrite one can rewrite URLs at response time in IIS. I want to be able to do this from codebehind so that I can save a file with rewritten URLs (such as sitemap.xml). Is this possible in VB/C#? I can't seem to find any built in way to do this.

Alternatively, is there any way with Outbound rules through IIS to ReWrite URLs that are inside the innerHTML of a specific html item, and not an attribute?

I've started to write my own .NET class to do this (load rewrites from web.config on class instantiation, the call a function passing the unwritten URL to receive back a rewritten one), but while the basic solution to get simpler rewrites working is quite trivial, the complete solution doesn't seem to be trivial at all.

I actually found the answer here:

http://forums.iis.net/t/1163122.aspx?Rewriting+javascript+code+possible

You can rewrite the links within the javascript code by using outbound rewrite without specifiy the matching scope. The rule looks like:

  <rule name="Rewrite internal link"> <match filterByTags="None" customTags="" pattern="https://internal/" /> <action type="Rewrite" value="https://extenal/" /> </rule> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM