0

i have table "Address" in Database in which address are saved by Post codes/Zip Codes

i want to retrive these address by postCode But Its is Not working

Post code formate = Le2 2SN

here is my code

  [Route("{id:length(6)}")]
        public IHttpActionResult GetAddress(string id)
        {
            Address address = (db.Addresses.FirstOrDefault(x=>x.postCode == id.ToUpper() )) ;

        }

Kindly help me . thanks

1 Answer 1

2

Try below code:

[Route("api/YourControllerName/{id:length(6)}")]
public IHttpActionResult GetAddress(string id){ // }

Note: your Post code format looks like it has 7 characters which include a space character. If that's your correct format, you need to change the length to 7.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.