-2

I have a simple actionMethod. I was just trying to Test the actionMethod using a QueryString but instead of returning Content i get this Error ): Yellow Screen of death ): Stated that :

A potentially dangerous Request.Path value was detected from the client (&).

QueryString:

http://localhost:63594/Home/LikePost/UserId=1&EntryId=1

ActionMethod:

// Like a Post.
public ActionResult LikePost(int UserId, int EntryId)
{
   return Content("User Id  Is  : " + UserId + "Post Id  is : " + EntryId);
}
LarsTech
  • 80,625
  • 14
  • 153
  • 225
Rehan Shah
  • 1,505
  • 12
  • 28
  • 1
    Possible duplicate of [A potentially dangerous Request.Form value was detected from the client](https://stackoverflow.com/questions/81991/a-potentially-dangerous-request-form-value-was-detected-from-the-client) – Kenneth K. Feb 12 '19 at 17:46
  • i checked that one.. @KennethK. but i can't findout my solution... – Rehan Shah Feb 12 '19 at 17:47
  • 1
    Possible duplicate of [Getting "A potentially dangerous Request.Path value was detected from the client (&)"](https://stackoverflow.com/questions/6025522/getting-a-potentially-dangerous-request-path-value-was-detected-from-the-client) – Roman Marusyk Feb 12 '19 at 17:48
  • 2
    Should be _http://localhost:63594/Home/LikePost?UserId=1&EntryId=1_ or _http://localhost:63594/Home/LikePost/1/1_ – Steve Feb 12 '19 at 17:49
  • What's wrong with my actionMethod and QueryString.....why i am getting this ? – Rehan Shah Feb 12 '19 at 17:49
  • @Steve ): Thanks – Rehan Shah Feb 12 '19 at 17:51
  • It looks like your querystring is missing a "?". Try popping one in between the trailing / of the address, and "UserId" – CodeMonkey Feb 12 '19 at 18:00

1 Answers1

1

My Problem was with a QueryString.

QueryString in Question: http://localhost:63594/Home/LikePost/UserId=1&EntryId=1

Corrected QueryString: http://localhost:63594/Home/LikePost?UserId=1&EntryId=1

I tried this :

/LikePost/...

but the Correct one was :

/LikePost?...

Rehan Shah
  • 1,505
  • 12
  • 28