Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The causes and Solutions of the invalidity of Ajax.AjaxMethod in IIS7

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is to share with you about the reasons for the invalidity of Ajax.AjaxMethod in IIS7 and how to solve it. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Recently, when I used the Ajax.AjaxMethod method, everything was fine under the server of asp.net. When I used iis, I couldn't find the cs class in js. I was depressed and messed around for most of the day, and finally found the cause of the error.

Because I used iis7 to publish the website, I added the tag in the web.config location file.

My problem is caused by not noticing the problem with the iis version. What a sad show!

Write down all the things that should be paid attention to in the whole method now, and it is also convenient to read it later. I hope the experience can let people who encounter the same mistakes see and save a little precious time. After all, is life valuable? spend less effort and lose a few hairs. Haha.

Find a comprehensive article on the Internet directly, don't scold me for plagiarism.

To use AjaxMethod, you need to meet the following points:

1. If you don't have an ajax.dll file yet, download one first.

2. Add ajax.dll to the project reference: right-click the project name-- "add Project reference"-- browse in the solution Explorer of VS, and find ajax.dll to confirm.

3. Add nodes to webCofig

If it is IIS7, you need to add it in.

Add to the CS program

The code is as follows:

Protected void Page_Load (objectsender,EventArgse)

{

Ajax.Utility.RegisterTypeForAjax (typeof (ClassName)); / / ClassName is the class name of this CS file

}

Write the CS method, preceded by [Ajax.AjaxMethod ()]

If you want to enable session to be called in AjaxMethod, write: [Ajax.AjaxMethod (HttpSessionStateRequirement.Read)]

Such as:

The code is as follows:

[Ajax.AjaxMethod ()]

Public string GetAddress (string UserID)

{

String Address= ""

/ / do somthing to get the address here

Return Address

}

Note that the method should be written as public, otherwise it will prompt "this property or method is not supported" when called in JS.

4. Make sure there are tags on the page.

5. Add the class name when calling in the JAVASCRIPT of ASPX, such as:

Var address = ClassName.GetAddress ('123'). Value

The above are the reasons for the ineffectiveness of Ajax.AjaxMethod in IIS7 and what are the solutions. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report