I did something similar - its a .net 7 project and doesnt have any web.config files, We view XML config as a bit of a step backwards so dont want to go to the lengths of creating them for this.
However as its just one rule and it will never need to change we implemented it in apps configure method when the web host is built :
var rewriteOptions = new RewriteOptions().AddRewrite("(?i)XX/(.*)", "/xx?yy=$1", skipRemainingRules: true);
app.UseRewriter(rewriteOptions);
Rewriting URL to mask query string in umbraco 11.
I have a render mvc controller (/Test/)
That page has a query string parameter passed into it (/Test/?number=123) and in the overridden index action I have
var number = ControllerContext.Request.Query["number"]
What I would like to do is mask that query string param from the users so they just see /Test/123
If this was a normal MVC project I'd just stick a route attribute on the action, but that doesnt work in this case.
Any ideas?
You can add a rule to the 'rewrite' section of the web.config, something like this:
Let me know if you need help setting this up in the web.config in V11.
Hi
Thanks for the response.
I did something similar - its a .net 7 project and doesnt have any web.config files, We view XML config as a bit of a step backwards so dont want to go to the lengths of creating them for this.
However as its just one rule and it will never need to change we implemented it in apps configure method when the web host is built :
is working on a reply...