1

I have created web application.I am giving one of web page to client as api.Client can pass parameter to web page like below

Ex: www.domainname.com/Testpage.aspx?name=pinky&city=pune&number=xxxxxxxx

In same page Testpage.aspx,I am accessing/fetching querystring like below.

string s= Request.Querystring["name"]; 

I am not sure how client can call api.I mean to say from browser or code throught.Whether client use urlencode or not?

from code

www.domainname.com/Testpage.aspx?name=Server.UrlEncode("pinky")&city=Server.UrlEncode("pune")&number=Server.UrlEncode("xxxxxxxx")

will below code work ? or does i need to decode?If client did not use Encode then decode work fine?.I want user querystring value further processing and insert into table.

string s= Request.Querystring["name"];

1 Answer 1

1

You need not decode it. If they have entered special characters and not encoded then it will not reach your server-side code at all because it will throw a bad request error. If they have encoded at their end then it will be automatically decoded at your end.

Even If they have not encoded, Your decode will work fine.

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

2 Comments

Hi Anoop H.N,thanks for ur reply.Client call my url and pass value.I am fetching it using request object.
In that case, You need not decode it. Because, If they have entered special characters and not encoded then it will not reach your server-side code at all. If they have encoded at their end then it will be automatically decoded at your end.

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.