Remove all .axd files from a webpage in ASP.NET 4.0

给你一囗甜甜゛ 提交于 2019-12-12 02:08:57

问题


I have added Ajax ToolKit in my website, but due to heavy load on the page we want to remove the Ajax Tool Kit.

To remove I deleted the file from the bin folder, Removed the control tab from Tools.

Now when I run the website, I see certain Webresource.axd? and Scriptresource.axd? script files in the project.

One file is too heavy around 55 KBs which affects the load time of the page.

Note: I am using Script Manager and update panel on the page, but all reference to Ajax ToolKit is removed. my project is a website in .NET 2010 using 4.0 framework.


回答1:


To get rid of such unnecessary .axd files use Ajax.dll from Microsoft and wirte your own code for it. example for using Ajax is as follows.

Suppose i am using Multiple Delete function on button click and i dont want to use Update panel due to page load try this.

using Ajax;

Register your control on Page Load event page_Load

Ajax.Utility.RegisterTypeForAjax(typeof(Admin_UserControls_Delete));

method

[Ajax.AjaxMethod()]
 public int deleteRecords(int ID,string spName)
 {
   // delete code block
 }


> In your **markup source on client click of button** call the javascript.

function callbackmethod(response) {
        if (response.value > 0) {
            alert("Record deleted Successfully");
            window.location.reload();
        }
        else {
            alert("Can Not Delete Record,It is being Used");
        }
}

function DeleteMultipleRecords() {

    //delete block to get the param values 
  var str = Admin_UserControls_Delete.deleteRecords(param1,param2,callbackmethod);
}


来源:https://stackoverflow.com/questions/7564940/remove-all-axd-files-from-a-webpage-in-asp-net-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!