The company I work for would like a potential customer to use their phone number right after the .com/ in their domain to pull up sales quotes for that potential customer.
This will map any URL that consists of exactly 9 numbers (and nothing else) e.g. mydomain.com/123456789 to the "quotes" action on the "sales" controller. Register this before the default route. It won't affect existing routing.
Member
1 Points
1 Post
How to route using mydomain.com/PARAM
Oct 16, 2018 10:54 PM|anthony@hthproject.com|LINK
The company I work for would like a potential customer to use their phone number right after the .com/ in their domain to pull up sales quotes for that potential customer.
For example, if the website is: www.mysite.com and the potential customer's phone number is 5551112222 they would like to be able to go to: Https://www.mysite.com/5551112222
Then the site will display all sales quotes it has for that customer based on their phone number.
What I can't find is how to do this in the routing. Not just that, but how to do it AND not screw up the routing for the rest of the website.
I'm used needing www.mysite.com/Controller/Action/Id
In this case its more like www.mysite.com/id
Any suggestions?
All-Star
194857 Points
28100 Posts
Moderator
Re: How to route using mydomain.com/PARAM
Oct 17, 2018 08:47 AM|Mikesdotnetting|LINK
Map a new route with a constraint:
This will map any URL that consists of exactly 9 numbers (and nothing else) e.g. mydomain.com/123456789 to the "quotes" action on the "sales" controller. Register this before the default route. It won't affect existing routing.
https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/controllers-and-routing/creating-a-route-constraint-cs
You will want to confirm the expected format of the telephone numbers with the customer and adjust the Regex expression in the constraint accordingly.