I am trying to rewrite a url in an httpmodule. If I have the string “/learning/index.aspx”. I want to rewrite it to “/learning/pages/index.aspx”
The rewrite will always put the “pages” in the same position in the string, before the last “/”, so “/index, would become /page/index.aspx, or /topics/topic1.aspx, would become /topics/pages/topic1.aspx.
What would be the correct c# code to do this?
Try this as an example:
You can use
LastIndexOfto find out where the last slash is, and insert your “/pages” string from there.