Hey I would love to know what you think while reading my posts. Please comment!.

Asp.Net Web Service Case Sensitivity Issues

I have been building Asp.Net Web Services (.asmx) for a while now, and never run into this issue before.

System.ArgumentException: Invalid method name 'helloworld',  method names are case sensitive.   The method name 'HelloWorld' with the same name but different casing was found.
    Parameter name: methodName
       at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
       at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
       at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
    

This happens when invoking the web service method directly from the browser when testing. If you call the service via Scripts everything works fine.

A solution to this problem is to give the methods a MessageName

<WebMethod(MessageName:="helloworld")> _
    Public Function HelloWorld() As String
        Return "Hello World"
    End Function

The only different is that you are putting the MessageName property in lowercase.

Seems to fix the problem, not sure what causes the problem, so I will look into it more.

I am always interested in hearing back from those who read my blog. Please leave a comment if you found this useful, want to suggest any changes to my code, or anything else! Thanks!

About Me

Tim James I'm Tim, a web applications developer from Glasgow, Scotland. Currently working for Kingfisher Systems Ltd, building bespoke systems within the Car Auction industry.

  • C#
  • VB.NET
  • ASP.NET
  • .NET MVC
  • Web API
  • Razor
  • HTML5
  • CSS3
  • jQuery
  • WCF
  • SQL
  • knockout.js
  • Angularjs
  • AJAX
  • APIs
  • SignalR
Why not follow me on twitter? Follow me on Twitter