Skip URL as get parameter?

I am trying to pass u url as a parameter to the get method. I defined a route that accepts the {* url} parameter so that I can send "/" characters without separating my parameter. As soon as the url has ":" (for example, in http: or localhost: 3857), the method never hits.

The Html.ActionLink method implements this parameter itself, but it does not seem to have eluded ':'. I cannot avoid this manually, because then the escape characters get the same Html.Actionlink method escaped.

any ideas?

+6
asp.net-mvc
source share
3 answers

Use EncodeUrl before passing it, and then decode it on the other side.

+3
source share

I ran into the same problem. I ended up removing Html.ActionLink and replaced it with:

<a href=" Movies?id=@item.ID ">@item.Title</a> 

@ item.ID is the URL returned from the netflix api, e.g. http://api.netflix.com/catalog/titles/series/70021357/seasons/70021357 . Now my url looks like this: / Home / Movies? Id = http: //api.netflix.com/catalog/titles/series/70021357/seasons/70021357 and I just used Request.QueryString to get the value in the controller:

 Request.QueryString.Get("id") 

Probably not perfect, but it works for now.

+1
source share

This is a bit of a hack, but you can replace the ':' with "% 3A" (this is a screened form) and see what ActionLink does with it. If this slips away again, you will have to replace the double-shielded version with ":" on the server, otherwise just replace "% 3A" with ":"

0
source share

All Articles