AJAX.NET 1.0 Configuration Error 解决方法

AJAX.NET 1.0 Configuration Error 解决方法

早上朋友在发布ajax项目时候出现Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified 的错误.
先将解决办法传上来分享下.
这个问题产生的原因还是出在微软本身,原本我们发布网站的时候都会自动生成dll文件到程序的bin目录。但是AJAX.NET 1.0无法自动添加关键dll文件到bin目录。因此需要我们手动添加。
方法很简单,找到你安装AJAX.NET 1.0的目录,一般是C:/Program Files/Microsoft ASP.NET/ASP.NET 2.0 AJAX Extensions/v1.0.61025把里面的System.Web.Extensions.dll文件System.Web.Extensions.Design.dll文件复制到bin目录下就可以了。当然复制哪个文件要看Web.config文件的异常信息而定
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用 AJAX 用 ASP.NET 后台方法可以通过以下步骤实现: 1. 在 ASP.NET Web 应用程序中添加一个 Web 服务 (Web Service),或者一个 Web API 控制器 (Web API Controller)。 2. 在 Web 服务或 Web API 控制器中创建一个可供 AJAX 用的方法。 3. 在 ASP.NET 页面中添加一个 ScriptManager 控件,并启用 ASP.NET AJAX。 4. 在页面中使用 JavaScript/jQuery 编写 AJAX 用,将请求发送到 Web 服务或 Web API 控制器中的方法。 下面是一个简单的示例: 1. 创建一个 Web 服务或 Web API 控制器 ```csharp // Web 服务 [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] [System.Web.Script.Services.ScriptService] public class MyWebService : System.Web.Services.WebService { [WebMethod] public string HelloWorld(string name) { return "Hello " + name + "!"; } } // Web API 控制器 public class MyApiController : ApiController { [HttpGet] public string HelloWorld(string name) { return "Hello " + name + "!"; } } ``` 2. 在 ASP.NET 页面中添加 ScriptManager 控件,并启用 ASP.NET AJAX ```html <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyPage.aspx.cs" Inherits="MyNamespace.MyPage" %> <!DOCTYPE html> <html> <head runat="server"> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <asp:ScriptManager runat="server" EnablePartialRendering="true" /> </head> <body> <form id="form1" runat="server"> <div> <input type="text" id="name" /> <button id="helloButton">Say hello</button> <div id="result"></div> </div> </form> <script type="text/javascript"> $(document).ready(function () { $('#helloButton').click(function () { var name = $('#name').val(); $.ajax({ type: "POST", url: "MyWebService.asmx/HelloWorld", // 或者 "api/MyApi/HelloWorld" data: JSON.stringify({ name: name }), contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { $('#result').text(response.d); }, error: function (xhr, status, error) { console.log(xhr.responseText); } }); }); }); </script> </body> </html> ``` 在上面的示例中,我们使用了 jQuery 库来简化 AJAX 用,通过给按钮添加一个 click 事件来触发 AJAX 请求,将用户输入的姓名作为参数传递给后台方法,并将返回结果显示在页面上的一个 div 元素中。 ASP.NET Web 应用程序中的 Web 服务和 Web API 控制器都可以使用这种方式来实现 AJAX 用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值