View Full Version : [CLOSED] Calling Web API and accessing page serialized fields

Jul 18, 2015, 11:15 AM
I want to access some page all fields values inside an ASP.NET Web API method as Dictionary, please guide how to achieve that, I want to implement a general purpose code so that ASP.NET Web API should be able to read all fields values passed from client-side as JSON on HttpRequest. This is what I have done so far but the service cannot read any field values of the page. Please guide Thanks

ASP.NET Web API controller for service myService:

[AcceptVerbs("POST", "GET")]
public string Test(HttpRequestMessage requestMessage)
var values = requestMessage.Content.ReadAsAsync<Dictionary<string, string>>().Result;
return string.Join(",", values.Values.Select(x => x));

ASP.NET Page declaration:

<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server">
<ext:TextField runat="server" ID="txtName" FieldLabel="Name" />
<ext:TextField runat="server" ID="txtEmail" FieldLabel="Email" />
<ext:Button ID="btnSave" runat="server" Text="Save">

Jul 20, 2015, 4:53 PM

Please try to remove Type="Load". Does it help?

Jul 21, 2015, 4:48 AM
Hi Daniil,
Removing "Type = Load" creates big query-string which results this error:

HTTP Error 404.15 - Not Found
The request filtering module is configured to deny a request where the query string is too long.

Please suggest, we are also trying to write our own method to achieve this like:

var serializeControlValues = function () {
// App is object
// Convert object to array
var arrControls = Object.keys(App).map(function(k) { return App[k] });

// Filter array and convert to object for json
var arrControlsByXType = arrControls.filter(filterType);
var objControlWithValue = {};
for (var i = 0; i < arrControlsByXType.length; i++) {
var cnt=arrControlsByXType[i];

return JSON.stringify(objControlWithValue);

And then passing the value return from this function as extra-parameter to our web-api controller method. But instead of writing our own, I want to do it with some native functionalities provided in Ext.Js / Ext.Net, please advise.

Jul 21, 2015, 6:04 AM
Okay, I need to investigate in details. Could you, please, provide a simple test project to reproduce the problem?

Jul 23, 2015, 4:44 AM
Hi Daniil,
I have changed our approach now instead of calling web api, we have directly calling the direct event so that I can easily get the control values automatically, basically I wanted a general purpose handler in web api which was not working, further I wanted to publish a bus in from web-api method even that also not working, so I ended up placing a global event handler of a button click in my base page which will be execute for all child pages I just need to make sure that button should refer to correct base page event handler name. That will serve our purpose and you may close this thread. Thanks