简体   繁体   中英

url parameter passing phone number e.g. +1234 , how to retrieve it e.g. abc.com/save/xyz/+123

We have URL in which we are passing name and phone number eg abc.com/save/xyz/+123

this url is coming from client so we can't change it but how can I retrieve it in backend? I have tried every possible way but Can't find a solution. If I remove + from the phone number then it works but I can't remove + sign from the URL.

In controller, I have a function for eg

[HttpGet]
public ActionResult Save(string name,string phoneNo)
{
...
}

Please let me know what should I do so phone number can be access through phone no.

Can you please check with this

You need to add Attribute Routing

[HttpGet]
[Route("Save/{name}/{phoneNo}")]
public ActionResult Save(string name,string phoneNo)
{

}

For more detail please check https://devblogs.microsoft.com/aspnet/attribute-routing-in-asp-net-mvc-5/

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