【发布时间】:2014-01-13 12:58:47
【问题描述】:
我有以下问题:
在 Visual Studio 2013(ASP.NET WebForms 应用程序)中创建的项目上未完成来自 WebMethod 的调用。例如,如果我在 Visual Studio 2008 中创建一个项目并迁移到 VS 2013 可以正常工作。仅当我在 Visual Studio 2013 中创建新项目时才会出现此问题。控制台中没有错误消息。 WebMethod 只是没有被调用。没发生什么事。我搜索了很多,但一无所获。
ASPX 代码:
<%@ 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>
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
有没有人尝试过或知道解决方案?我不知道该怎么办......
编辑:
伙计们,我现在又发现了一个信息:
仅在 VS2013 中工作:
-新项目。 -Web - ASP.NET Web 应用程序。 - 选择模板“空”。 - 插入页面“Default.aspx”,WebMethod正常工作...
现在,如果您新建一个项目并选择模板“WebForms”,则不起作用...
可以交叉引用吗?还是一些不同的设置?
【问题讨论】:
-
Você vai querer dar uma olhada nesse site para Português: br.stackoverflow.com
-
问题必须是英语。
-
谢谢,我会在那里问问题..
-
我也翻译了这个问题..
-
“webmethod 未被调用”是什么样的?您是否在客户端收到错误,可能在调试器控制台中? JavaScript 正在执行吗?
标签: asp.net vb.net visual-studio-2013 webmethod pagemethods