.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Deserializing HttpRequest.Params

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net


I've read that using the XmlTextReader is much faster than loading an XmlDocument but I can't seem to get it to work with Xml contained in an HttpRequest.Params.

Also, when I try to deserialize some XML held in a HttpRequest.Param using an XmlDocument.LoadXml I get an exception saying that it's not liking the XML declaration.  

The '=' character, hexadecimal value 0x3D, cannot be included in a name. Line 1, position 13.

View Complete Post

More Related Resource Links

Deserializing nullable model properties


Hi everyone,

I'm posting Json data to an action that has a model class as a parameter using the JsonValueProviderFactory. Everything works except for any nullable properties in the model, such as double? and bool? - they always materialize as null, even if a value is posted.

I'm not sure if this issue is specific to the JsonValueProviderFactory, or MVC in general.

Being new to MVC I'd appreciate any help with this issue.


Serializing and Deserializing Problem


Hi, I used serialization and de-serialization in my project. 

Below is my class and form code for your reference.

Public Class Serialization
    Public Function XmlSerialization(ByRef objEmployee As Object) As String
        'XML Serialization
        Dim encoding As New UTF8Encoding()
        Dim Serializer As New XmlSerializer(objEmployee.GetType())

Serializaing/deserializing XOMLs with custom activities that have properties of ISerializable types

I have custom activities that have dependency properties of types that implement ISerializable. When they are serialized/deserialized to XOML, the ISerializable-implied functionality is ignored and the standard reflection-based SerializableAttribute behavior is invoked. This poses a serious problem since the types require precise control over their serialization to ensure that proper internal state is maintained across serialization boundaries. I am aware of the WF custom serialization methods as mentioned in Tom Lakes' blog post, but they seem to require the DesignerSerializerAttribute attribute on all custom types. This is a problem because the types are business objects shared across many (non-WF) applications and they are part of a seperate code base to which I have no access. Is there a different method for getting custom serialization? And what is the reasoning behind the WF team choosing to ignore the very basic ISerializable attribute which is supported by every other .NET API across the framework? Thanks in advance.

DataContractJsonSerializer: Problem when deserializing the Date

Sorry for cross-posting. I posted the same question on the Silverlight forum, but it has not received a single answer yet. The majority of folks there must be more interested in UI than in more fundamental stuff.     Hello everyone! Let's say we have the folllowing POCO classes: public class PocoObject : List<PocoPropertyData> {     public PocoObject() {}     public override string ToString()     {         var parts = new List<string>();         foreach (var pd in this)             parts.Add(string.Format("{{N=[{0}], Type=[{1}], V=[{2}]}}", pd.N, pd.V == null ? typeof(object) : pd.V.GetType(),  pd.V));         return string.Join(",", parts);     } } public class PocoPropertyData {     public string N { get; set; }  // the property name     public object V { get; set; }  // the property value } As you can see, the PocoPropertyData can hold value of any type. When I execute the following code in both .NET 4 application and Silverlight 4 application: ========================================================= var poco = new PocoObject {       { new PocoPropertyData { N = "DateTimeField", V =  Da

Deserializing Problem when build proxy by svcutil from WSDL

Hi, I got a WSDL from a third-party company and have to build a proxy to fetch data. I used svcutil *.wsdl to generate code and config file. Using the proxy I wondered why I got unexpected results: The return value is alway 0 and the string field CTWS_ReturnMsg always empty even if the server sent values. Could anybody help me? Here the WSDL and afterwards the http-traffic (from Wireshark): <?xml version="1.0" encoding="utf-8"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://CEITONWebService.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://CEITONWebService.org/">     <wsdl:types>         <xs:schema xmlns="http://CEITONWebService.org/" xmlns:mstns="http://CEITONWebService.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://CEITONWebService.org" targetNamespace=&q

HTTPRequest web.config: files only?

Hello.I'm trying to use HTTP handler.this is the URL to my web service:  http://localhost/VirDir/WebService/ApplicationsWS.asmx/Reporthttp://localhost/VirDir/WebService/ApplicationsWS.asmx/FlushI want handler to each one (Report / Flush) but they are not actual files.for the Report I tried (in web.config - httpHandlers):path="Report*"path="*Report*"path="*Report"but nothing work.just this work:path="*"and with this I can't direct to Report or to Flush.Can I set it by query string parameter?What can I do?Thanks.

Problem deserializing a collection (CollectionBase)


I am attempting to expose WCF services to AJAX-enabled web pages. Everything is working fine, but I can't for the life of me figure out who to make this work with collections (inheriting from CollectionBase). This is my current class structure:


Code Snippet


public class SalesOrder {

private string _number;

private DateTime _date;

private Customer _customer;

private SalesOrderItemCollection _items;

How can i access to params and args defined in parent activity from custom NativeActivity


There is a scenario that the custom NativeActivity need to access to params or args defined in parent activity. What i have done as below

 protected override void Execute(NativeActivityContext context)


   WorkflowInstanceProxy proxy = context.GetExtension<WorkflowInstanceInfo>().GetProxy();

   Activity root = proxy.WorkflowDefinition;

   Activity rootChild = WorkflowInspectionServices.GetActivities(root).ElementAt(0);

   EditingContext ec = new EditingContext();

   ModelTreeManager mtm = new ModelTreeManager(ec);


   ModelItem modelItem = mtm.Root;

   ModelProperty c1 = modelItem.Properties["Variables"];

   ModelItemCollection c2 = c1.Collection;

   dynamic c3 = c2[0].GetCurrentValue();

   string value = c3.Get(context);


Apparently it is not possible to access to external params with local context so the error prompt "An activity can only access its own implementation variables."

My question is how to get it ? Is there another easy way to do so ?



be together be stro

can we use optional params in C# while defining service contracts?


I mean can I do something like this:

List<String> GetEmployees(String EmployeeId,  String DepartmentID= "00");

and then implement it the same way as below

List<String> GetEmployees(String EmployeeId, String DepartmentID= "00")




I tried this, but it didn't work. Its always expecting DepartmentID when I tried to use invoke 'GetEmployees' using service reference.

Trouble deserializing ArrayOfString from Apache Axis WebService



I'm trying to call a webservice hosted on Apache Axis. It's probably written in Java. (Speficially, it's a service from Cisco CallManager returning call detail files.)
The WSDL contains the following snippets:
schema targetNamespace="http://schemas.cisco.com/ast/soap/"

HttpRequest with list RSS does not work



I'm trying to fetch the output of a list RSS page with a HttpRequest object on a SharePoint site.
The SharePoint site is hosted elsewhere so I don't have any control over the settings there.

The RSS url of the list looks as follows (changed the hostname for this post):

When I open this in the browser it works OK.
When I try to open this URL through the HttpRequest object the URL is being redirected to this URL:

Which obviously gives the error that the list does not exist there.
Why would this happen? When I try to open the default.aspx page of this site (URL = http://someSharePointSite/NewsPortal/Pages/default.aspx) then it works OK even through code. The site is open for anonymous access, so an authentication issue can not be the cause here I think ? Even then it wouldn't make sense that I'm

Deserializing a JSON array of mixed types



I'm having trouble deserializing a JSON array of mixed types using the DataContractJsonSerializer class. I've spent a bunch of time looking for a solution to no avail, so I thought I'd go ahead and ask here.

Basically, I am getting a JSON string like the one below. I'd like to get the array to deserialize into an List where position 0 has an Int32, position 1 has a String, and position 2 has an instance of my custom class.

"Mr. Smith",
"name":"main street",

How do I - pass multiple params from multi-select drop down on one report to another via action


Report 1 - 3 params:  @Status =Y,N  @FromDate, @ToDate.  Report one shows 2 cols (Status, Total). 

 @Status gets values from shared dataset - getStatus

Status      Totals
[Status]    [Total]

I created an action [Total] when clicked runs another report that accepts the same 3 params (Status, FromDate, ToDate) and works fine if i only select one of the status' from the status param drop down.

I am trying to create an action on [sum(Total)] that will run the same 2nd report with both status' selected.  Show it should show me details of all Y and N

The second report will work if i set the 2nd report @Status param to no default value.  But i want a user to be able to run the 2nd report by itself if needed so i set the @Status param to Get Values from a Query, which get the same dataset as report 1 which is getStatus.  It will not populate the 2nd report Status field when I do this.  I am forced to set it to no default values.  Is there a way to pass both the Y and N from report 1 to report 2 and still keep the drop down multi-select box on report 2 for Status?


CURSOR and params


hi all

i have a question about an sql statement and i have no solution for it ...

i have update sp for users table ,,, i want to store in "Transactions Table" which exactly the fields updated and what is the old value and new value ,, just the updated !!

look at this sp code :

CREATE PROCEDURE [dbo].[spUpdateUser]
	-- Add the parameters for the stored procedure here
	@user_id int, 
	@user_name nvarchar(50), 
	@user_real_name nvarchar(100), 
	@user_email nvarchar(50), 
	@user_password nvarchar(100)

     Insert statements for procedure here
    DECLARE Cnames_cursor CURSOR
			FOR SELECT column_name FROM information_schema.COLUMNS WHERE table_name LIKE 'users' ORDER BY ordinal_position
OPEN Cnames_cursor
DECLARE @column_name sysname 
FETCH NEXT FROM Cnames_cursor INTO @column_name

   IF (@@FETCH_STATUS <> -2)
      SELECT @column_name = RTRIM(@column_name) 
      declare @usersParm nvarchar(50);
      set @usersParm = '@@column_name'
         if(@usersParm <> (select @column_name from users where user_id = @user_id))
			declare @useroldVal nvarchar(100);
			select @useroldVal = @column_name FROM users where user_id = @user_id
-- dbo.AddTotransactions_for_update column_name , the old value , th

Deserializing with DataContractSerializer by-pass member initialization?


I am really puzzled to understand why a member's initializer that constructs an instance of List<T> is not executed resulting in a NullReferenceException when I deserialize Book class, listed below. The DataContract is as follows and the comment indicates where  NullReferenceException is thrown :

namespace Bookshop {
    [ DataContract ]
    public class Book {
        string title;
        List<Person> authors = new List<Person>(); // Initialize authors
        public Book( string title, params Person[] author ) {
            this.title = title;
            this.authors.AddRange( author );
        [ DataMember (Name="ti") ]
        public String Title    {
            get{ return this.title; }
            set{ this.title = value; }

Exception deserializing objects from older version



We have a fairly complex document structure for our application, which we are saving to disk using Binary Serialization. We came across the familiar problem, that when we incremented the version number of our application (to allow an MSI installer to upgrade it), the Deserialize method on files created with the old version no longer worked. After some research, I came up with the solution to define our own SerializationBinder, and implement a BindToType function that substututes the types. I've stuck the code for this below:

 Public Overrides Function BindToType(ByVal assemblyName As String, ByVal typeName As String) As Type
  Dim typeToDeserialize As Type = Nothing
  Dim ThisAssembly As [Assembly] = [Assembly].GetExecutingAssembly()

  If typeName Like "MyApp*" Then
   ' To return the type, do this:
   AddErrorMessage("Deserializing " & typeName & " " & ThisAssembly.FullName)
   typeToDeserialize = Type.[GetType]([String].Format("{0}, {1}", typeName, ThisAssembly.FullName))
   ' To return the type, do this:
   AddErrorMessage("Deserializing " & typeName & " " & assemblyName)
   typeToDeserialize = Type.[GetType]([String].Format("{0}, {1}", typeName, assemblyName))
  End If
  If typeToDeserialize Is Nothing Then

Performance issue with WCF deserializing base64 strings sent in SOAP body with CRLF


We have a big performance issue with the deserialization of base64 string in a WCF Client (C#) which is calling a web service to get PDF files. This service is a third party service not in .NET.

Server side, each PDF file is returned by the third party service as a base64 string. This base64 string is "formatted" in the returned SOAP envelope with carriage return + line feed (CRLF) every 73 characters. The third party provides a wsdl + XSD to described his service.

Client side, in the DataContract generated from the XSD, the DataMember (named "img") containing the returned PDF is declared as "byte[]" (which is logic). But we noticed that at runtime, once a message arrives, a lot of time is spent client side in the "WCF Soap Stack" before getting the PDF.

So we did some tests and discovered that after changing client side the DataMember "img" from "byte[]" to "string" (+ doing a Convert.FromBase64String() on "img"), the performance is incredibly improved (it depends on the size of the PDF).

We did next create a WCF Service to emulate the third party service. To send the very same data as the third party, we did save a soap body received from this third party into a XML file (response.xml) and we loaded + deserialized this one in our service.

In this service, we did f
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend