Recently done with the Ajax.ajaxmethod method, in the asp.net of the server under all normal, with IIS, JS is always CS class can not find, I was depressed, tossing the majority of days, finally found the cause of the error.
Because I am publishing the site is IIS7, so in Web.config location file <system.webServer>
My problem is due to the failure to notice the IIS version of the problem, resulting in ... The drama is sad!
Now the whole method to pay attention to all write down, but also convenient to see later, the hope of the encounter can let people encounter the same error to see, save a little precious time, after all, life is valuable, little God, less a few hair, haha ...
Directly on the Internet to find a comprehensive, don't scold me plagiarism ...
Use Ajaxmethod to satisfy a few points:
1, if there is no Ajax.dll file, first download a to
2. Add Ajax.dll to project references: Right-click the project name-"Add Project Reference" in the VS Solution Explorer-Browse, find Ajax.dll OK
3, Webcofig If it is IIS7, you need to add <add name= "ajax" verb= "Post,get path=" ajax/* in <system.webServer></system.webServer>. Ashx "Type=" ajax.pagehandlerfactory, Ajax "/>
In the CS program, add
Copy Code code as follows:
Write CS method preceded by [Ajax.ajaxmethod ()],
If you want to make the Ajaxmethod inside can call session, write: [Ajax.ajaxmethod (Httpsessionstaterequirement.read)],
Note that the method should be written public, otherwise the call in JS will be prompted "Do not support this property or method"
4, to ensure that the page has <form runat= "server" ></form> label.
var address = classname.getaddress (' 123 '). Value;