I'm not able to fire a WebMethod
on a project created in Visual Studio 2013 (WebForms Application).
If I create a project, for example, in Visual Studio 2008 and migrate to Visual Studio 2013, it works correctly. If I create a new project in Visual Studio 2013 the above problem occurs.
I searched a lot to see if I needed to add a key in web.config
, but I did not find anything about it.
Follow the ASPX code:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="TestePageMethods._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server" />
<script type="text/javascript">
function testeClick() {
PageMethods.SayHello("Name");
}
</script>
<input type="button" value="Say Hello" onclick="testeClick();" />
</form>
</body>
</html>
And aspx.vb:
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
<System.Web.Services.WebMethod(True)> _
Public Shared Function SayHello(ByVal name As String) As String
Return "Hello " & name
End Function
End Class
EDIT: Personally, one more information I discovered now:
Working only on VS2013:
- new project.
- Web - ASP.NET Web Application.
- Select the "Empty" template.
- Insert a "Default.aspx" page, WebMethod works normally ...
Now, if you create a new project and select the "WebForms" template, it does not work ...
Is there no cross-referencing? or a different setting?