ASP.Net & IIS URL Rewrite Module - rewrite arbitrary URLs from code?
-
Banging my head on this one.
I have IIS URL Rewrite Module set up. Cooool. It works.
In ASP.Net, I have an arbitrary URL, but I know it belongs to the current site. Say it's the Request.Referrer, and I've validated it.
Is there anyway for me to call a bit of code that will:
- Take as input the arbitrary URL
- Run it through the URL Rewrite module, using the already existing ruleset
- Spit out a rewritten URL, as per those rules
???
-
Request it from the webserver ?
-
Does this help?
-
@doctorjones said in ASP.Net & IIS URL Rewrite Module - rewrite arbitrary URLs from code?:
Does this help?
Doesn't seem to. If I put in my input as
category/100
, it should URL Rewrite tocategory.aspx?id=100
, based on the rules defined in web.config.
-
@lorne-kates said in ASP.Net & IIS URL Rewrite Module - rewrite arbitrary URLs from code?:
@doctorjones said in ASP.Net & IIS URL Rewrite Module - rewrite arbitrary URLs from code?:
Does this help?
Doesn't seem to. If I put in my input as
category/100
, it should URL Rewrite tocategory.aspx?id=100
, based on the rules defined in web.config.I see, that only works if outbound rules exist. But I don't want any outbound rules to actually fire. Hmm.
-
Sorry man, I've not used rewrites in a loooong time. It seems I've been spoiled by the luxuries of routing for too long ;-)
I'll keeping thinking about it though, maybe I'll jog my memory over breakfast or something.
-
@doctorjones said in ASP.Net & IIS URL Rewrite Module - rewrite arbitrary URLs from code?:
Sorry man, I've not used rewrites in a loooong time. It seems I've been spoiled by the luxuries of routing for too long ;-)
This. Why is rewriting still even a thing?
-
@masonwheeler said in ASP.Net & IIS URL Rewrite Module - rewrite arbitrary URLs from code?:
@doctorjones said in ASP.Net & IIS URL Rewrite Module - rewrite arbitrary URLs from code?:
Sorry man, I've not used rewrites in a loooong time. It seems I've been spoiled by the luxuries of routing for too long ;-)
This. Why is rewriting still even a thing?
Product was written long before routing was part of the .Net framework, and inertia has carried it since.
-
fuckit I just wrote my own.
- Load the rewriterules.config XML
- Parse out the rules I need into some simple-to-use objects, each with Teh Needful regex
- Put them in a collection
- Pass the collection a string and have it iterate