last day (15 days later) » 

16:41
Hello Mat
huzzah!
Sorry for troubling you. But I think I am not effectively conveyed about what I am doing
no problem, lunch time, I'm on my phone
<add key ="ValidatePassword" value="<url>?id=MyUserId&amp;password=MyPassword"/> is a REST url
thanks
will you please help me on how actually I need to create a GET call using the about url?
The problem is I am not sure about how to form a REST url
I mean form a REST url to consume it in my application
I am not developing the REST but I am using it
hmm I know my C#, but I don't do web dev.. not sure I can help here.
looks like you're building a query string.. I'm 99.99999% sure passing a password in there isn't a very good idea
but if that's what the service requires..
16:47
Ok, the reason why I went for a static MyUserId, MyPassword is to replace the same with actual values while forming the complete url
doesn't have to be static
yes it called as query string :) but part of the query string will vary...
in fact, they should be implementation details, encapsulated in an object that takes constructor parameters and exposes a method that returns the full url
I mean <url>?id=MyUserId&amp;password=MyPassword"/> is to validate user credentials <url>?id=UserId"/> to get user details
so I am trying to write a generic method that will get what url (validate user or user detail) and the corresponding parameters. Eg. for validate user, the parameters are userid and password and for user detail, the parameter is userid. so this generic method will get the url and the respective parameter(s) and do the replace logic to form the complete url
public static string BuildCompleteUri(this string source, IDictionary<string, object> uriParameters)
{

var completeUri = ConfigurationManager.AppSettings[source];
foreach (var uriparameter in uriParameters)
{
completeUri.Replace(uriParameter.Key, uriParameter.Value.ToString());
}
}
I see
why not use string.Format placeholders instead of Replace?
"?id={0}&amp;password={1}"
16:57
For ex to get a user detail the url here will be "http://<someurl>/user/Id=Userid?" so in the dictionary key will be "UserId" and value will be "234" and source string will be url I mentioned above
and then you can just string.Format(completeUri, id, password)
there are rest url's that takes too many parameters
I'm sure the framework has something to build query strings though.. using string.Replace just doesn't feel right
so I personally believe it will be hard to maintain the sequence, if it is a Replace I don't have to worry about sequence and the replace will handle it smoothly
180
A: How to build a query string for a URL in C#?

annakataIf you look under the hood the QueryString property is a NameValueCollection. When I've done similar things I've usually been interested in serialising AND deserialising so my suggestion is to build a NameValueCollection up and then pass to: using System.Web; using System.Collections.Specialized...

possibly relevant
16:59
thanks will look at it.
oh that looks even better:
404
A: How to build a query string for a URL in C#?

John BledsoeYou can create a new writeable instance of HttpValueCollection by calling System.Web.HttpUtility.ParseQueryString(string.Empty), and then use it as any NameValueCollection. Once you have added the values you want, you can call ToString on the collection to get a query string, as follows: NameVal...

NameValueCollection queryString = System.Web.HttpUtility.ParseQueryString(string.Empty);

queryString["key1"] = "value1";
queryString["key2"] = "value2";

return queryString.ToString(); // Returns "key1=value1&key2=value2", all URL-encoded
the second seems to the one that could fit me
but my point was mostly that you need to find a way to get rid of all these public static variables ;-)
globals are not very
:) sure will keeping try to understand oop and code accordingly
Keep hanging around on Code Review, and posting your working code there!
17:07
ofcourse I will. An huge chance to learn and help each other :)
Thanks Mat. you made my day. You too have a nice day!
I'm sure you'll get more answers on that post, too. Covering everything in one answer isn't something that happens often :)
Oh and come to The 2nd Monitor anytime, too!
Thank you :)

last day (15 days later) »