When I开发者_开发百科 made an AJAX call to an ASP.NET page, I had a mechanism to return some text based on QueryString parameters. Such as :
Response.Write("<text>");
But in the response, I got a lot of extra information about viewstate status. This does not happen in classic ASP or PHP. Also if I ask for the whole page, it returns it with the page directive
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Isn't it a bad idea on the part of ASP.NET to give away the information about backend implementation (.cs) ? How to avoid this extra information and pass only the required one?
Currently I am using PHP page for returning things for the same purpose. It works totally fine.
The easiest brute-force way to get around this issue is to make your Web service a generic handler (.ashx) instead of an .aspx page.
You shouldn't use Response.Write with AJAX calls, but rather update a control ie. set a Label's Text property. Can you tell more about which functionality you want? We might be able to give you an alternative solution.
Which AJAX implementation are you using (Microsoft's, or a third party) ?
Help me understand web methods?
http://randomactsofcoding.blogspot.com/2009/03/jquery-json-and-asmx-20-services.html
http://www.codeproject.com/KB/webservices/jsonwebservice.aspx
I would recommend you to use ASP.NET AJAX with ASP.NET, rather than raw AJAX (core AJAX). Use UpdatePanel control to make dynamic updates.
Regards, Mahendra Liya.
You probably have a configuration issue. Try running the page with query strings alone without AJAX calls.
Such executed aspx page (Without HTML) should return the text you seek with no "viewstate status". Plus it never returns the page directive if it was well executed.
精彩评论