Reputation: 8626
I have #
in my string.
and i am sending that string to my c# method on server side through ajax.
I am sending it as follows:
$.ajax({
type: "POST",
url: "http://localhost:5889/MobileEcomm/Service1.svc/validateLogin/"+EmailID+"/"+encodeURIComponent(Password),
crossDomain: true,
success: function (data) {
alert(JSON.stringify(data));
alert("Login Sucessfull!!!");
window.location = "viewOrders.html";
// do something with server response data
},
error: function (err) {
// handle your error logic here
alert("Error");
}
});
my Password string is : pass@#
My c# method structure:
public string validateLogin(string Email, string Password)
{
return Password;
}
Wheni get password parameter in c#, Its as follows:
pass@
When i make alert of
encodeURIComponent(Password)
Its:
pass%40%23
Why i am not getting same result (pass%40%23) as a parameter for password in my c# method???
Plaese help me.
Upvotes: 2
Views: 635
Reputation: 2217
If you are hosting your WCF Data Service on top of IIS+ASP.Net/WCF, then you may discover that there are certain characters that will cause the server to throw when they are contained in entity keys. The result is either a 400 Bad Request or 404 Not Found. In VS 2010 RC, you can potentially configure the server to support these characters, but first, let’s see what characters are considered “special”:
%,&,*,:,<,>,+,#, /, ?,\
If any of the above characters are used inside a string key for an entity, then querying for the entity will resulting in an error, whether you escape the Uri or not.
And you are using # in the URL so that's why it is not providing proper result.
check this link for solution on MSDN blog
you might also like to see this link as well, it will answer your second part of question why you are getting %40%23 as values.
Upvotes: 2