c# - The call is ambiguous between the following methods or properties - overloads with string and byte[] inputs -


adding posterity since couldn't find specific in googling endevors.

problem:

the call ambiguous between following methods or properties: 'system.web.httputility.urlencode(string)' , 'system.web.httputility.urlencode(byte[])'

note: issue specific to, @ least, overloaded methods accept string in 1 signature , byte[] in similar signature (see urlencode signatures above).

this issue presenting runtimebinderexception in partial using asp.net mvc4 happen in other environments. key urlencode has 2 overloads , runtime binder can't figure out overload use.

my solution:

although not optimal, casting input correct type seems give runtime binder enough of tip can resolve correct method signature use.

for example, here "failing" code threw above exception (from mvc4 partial - code contractor , i'm not proposing best way create anchor tag - yet illustrate specific issue nicely):

<a rel="nofollow"    href="https://twitter.com/share?text=check%20this%20out!%20@(viewbag.title)%20    @(httputility.urlencode(request.url.absoluteuri))%20%40codinghorror"    target="_blank">   twitter </a> 

and here is, rewritten casting:

<a rel="nofollow"    href="https://twitter.com/share?text=check%20this%20out!%20@(viewbag.title)%20    @(httputility.urlencode((string)request.url.absoluteuri))%20%40codinghorror"    target="_blank">   twitter </a> 

after fix, reloaded offending page , sure enough, poof!, worked.

happy trails!


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -