-1

I need to pass a string parameter as querystring parameter which should be optional.

public IHttpActionResult Test([FromUri] string Name, string Place)

Here I want Place as an optional parameter. I tried to use as string?Place=null. But It wont works for me. Let me know the solution for this.

2

2 Answers 2

0

You were close:

public IHttpActionResult Test([FromUri] string Name, string Place = null)
Sign up to request clarification or add additional context in comments.

Comments

0

if you don't want to sen Place just don't put it in your url

...controller/test?Name=name

if you need both parameters

...controller/test?Name=name&Place=place

and you have to use FromUri for both parameters

public IHttpActionResult Test([FromUri] string Name, [FromUri]string Place)

or maybe you can try dont'use at all

public IHttpActionResult Test( string Name, string Place)

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.