的WebMethod在Visual Studio 2013不叫(触发)由PageMethod的 [英] WebMethod not called (triggered) by PageMethod in Visual Studio 2013
问题描述
我有以下问题:
这是一个WebMethod,电话不被上在Visual Studio 2013(ASP.NET WebForms的应用程序)创建的项目完成。如果我创建一个项目,例如,在Visual Studio 2008,并迁移到VS 2013正常工作。只有当我创建一个新项目在Visual Studio 2013年有在控制台中没有错误信息出现问题。 WebMethod的只是不被调用。什么都没发生。我搜索了很多,但没有发现任何关于它。
The call from a WebMethod is not being done on a project created in Visual Studio 2013 (ASP.NET WebForms Application). If I create a project, for example, in Visual Studio 2008 and migrate to VS 2013 works correctly. The problem only occurs when I create a new project in Visual Studio 2013. There is no error message in the console. The WebMethod is just not being called. Nothing happens. I searched a lot but found nothing about it.
ASPX code:
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>
ASPX.VB code:
ASPX.VB code:
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
有没有人尝试解决这个还是知道?我不知道该怎么办...
Has anyone tried this or know of a solution? I have no idea what to do ...
编辑:
大家好,我现在才发现多了一个信息:
Guys, I discovered one more information now:
工作只在VS2013:
Working only in VS2013:
- 新项目。
-Web - ASP.NET Web应用程序。
- 选择模板空。
- 插入页面的Default.aspx,WebMethod的正常工作......
-New project. -Web - ASP.NET Web Application. -Select the template "Empty". -Insert a page "Default.aspx", the WebMethod works normally ...
现在,如果你创建一个新的项目,并选择模板的WebForms,不能正常工作...
Now, if you create a new project and select the template "WebForms", does not work ...
可以是交叉引用?还是有些不同的设置?
Can be cross-referenced? or some different setting?
推荐答案
我找到了解决我的问题:是什么prevented将WebMethod被称为是提及System.Web.Optimization。不知道他是怎么做的,但我不会的时候使用它,决定免去:
I found the solution to my problem: What prevented the WebMethod was called was the reference to "System.Web.Optimization". Not sure how he does it, but as I will not use it at the time, decided to remove:
System.Web.Optimization和Microsoft.AspNet.Web.Optimization.WebForms
"System.Web.Optimization" and "Microsoft.AspNet.Web.Optimization.WebForms"
也有必要除去的web.config如下:
It is also necessary to remove the web.config as follows:
<namespaces>
<add namespace="System.Web.Optimization" />
</namespaces>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms"
namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
<dependentAssembly>
<assemblyIdentity name="WebGrease" culture="neutral"
publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
现在一切OK!感谢大家谁的问题帮我! :)
All ok now! Thanks to everyone who helped me with the problem! :)
这篇关于的WebMethod在Visual Studio 2013不叫(触发)由PageMethod的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!