0

My Id values can contain asterisks:

Controller/Edit/191354*

This, of course, results in a server error:

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

I've read various posts on how to get around this, and it seems the simplest would be to pass the Id in as a query string instead:

Controller/Edit?id=191354*

If I do this in my views, I need not change anything else in my project. This is great, because embedded asterisks are a corner case and I'd prefer not to do a lot of work to get past this.

However, I'm having a terrible time try to use Html.ActionLink() in my view to generate such a link. I'm almost to the point of giving up and building the link by hand, but surely there must be a simple way to do this.

Darryl
  • 1,531
  • 15
  • 26
  • possible duplicate of [Getting "A potentially dangerous Request.Path value was detected from the client (&)"](http://stackoverflow.com/questions/6025522/getting-a-potentially-dangerous-request-path-value-was-detected-from-the-client) – balexandre May 16 '14 at 19:15
  • I saw that while researching, but it doesn't answer my question, and I think changing requestPathInvalidCharacters would be overkill for this. – Darryl May 16 '14 at 19:22
  • Do all of your ids contain an asterisk? If so, you could just remove it from the link and then add it back server side. I ralize that is a silly solution, but its quick! – bsayegh May 16 '14 at 19:32
  • No, only some. Yeah, I could encode/decode as a last resort. – Darryl May 16 '14 at 19:36

1 Answers1

0

Action link builds according to routes, you just need to change routes to make them use query string parameter instead of part in URL.

Dmitry Zaets
  • 3,289
  • 1
  • 20
  • 33