I have created a Web Application with an “asmx” page to allow web methods (Insert, Update, Delete) to act as a web service. I used a jQuery Post to communicate with the Web Method and all worked fine while working on my localhost. Once the Web App was deployed to server, when I try to access the Web Method from the browser example: “myDomain.com/myPage.asmx/Insert”, I kept on getting an error saying: “Request format is unrecognized for URL unexpectedly ending in ‘/Insert’.”
Apparently this was caused due to cross domain access origin issues. Cross-domain origin does not allow one domain to call a page/method from another domain. The Web Methods needed to allow access for cross-domain calls.
In my web.config, I add the following section under the section:
I created a global.aspx page and added an Application_BeginRequest method. In this method I declared access to cross-domain as shown below:
protected void Application_BeginRequest(object sender, EventArgs e)
Hope this helps 🙂