Wednesday, February 27, 2013

Telerik : The state information is invalid for this page and might be corrupted

if you get this error using Telerik (such as clicking back button in telerik grid),

"The state information is invalid for this page and might be corrupted" bla bla bla

just set EventValidation="false" in your aspx pages. Don't ask me why, or if you have other solution, let me know.

Never liked Telerik, but job requires it

Tuesday, February 26, 2013

your REST aren't REST - webapi rant

found a comment in a blog . I love it and I completely agree

"(Most programmers) _think_ they're doing REST (closer to 100% in PHP/Java/.Net/Rails circles), but really they're just doing ad-hoc RPC over HTTP with the message name in the URL/headers/body and arguments serialized as XML payload - essentially SOAP without all the heavyweight baggage. They really should stop calling this 'REST' for their own sakes: just call it HTTP-RPC and avoid embarrassing yourselves with buzzwords you have no business using."

Monday, February 25, 2013

PUT/DELETE method causes 500 internal server error

After you deployed your web api files to windows server IIS, and you find you get 500 internal server errors for PUT and DELETE method. it is because you have to enable those verbs first

1) Click your webapp in IIS
2) go to Handler Mappings
3) Look for "Extensionless" bla bla. There could be one, or few
4) Click Request Restrictions
5) Click Verbs tab
6) Enable all verbs, or add PUT and DELETE method in the textbox

Sunday, February 24, 2013

WebAPI Sucks

There, I've said it.

My personal choice is XML-based service.

Delivery ? Http
Works with Javascript? Yes
Works with JQuery ajax wrapper? Yes
Works with any modern programming language? Yes.
Multi-platform? Yes
Easy to develop ? Yes.
Easy to debug ? Yes
Service based ? Yes. CRUD Simply sucks and limited
No PUT / DELETE method - Awesome
Lifespan ? As long as HTTP and XML exists


Monday, February 18, 2013

how to see the generated SQL in .net Entities

((System.Data.Objects.ObjectQuery) res).ToTraceString()


res is your query object. easy eh?

LINQ and synonyms / linked servers

100% COPY & PASTE FROM :

http://netpl.blogspot.com/2008/06/linq-and-synonyms-linked-servers.html


LINQ and synonyms / linked servers

I've been asked if it's possible to perform joins across different databases using LINQ. The first obvious answer is yes, you just do inproc join using Linq To Objects and two different contexts:
from a in new List( context1.TheA )
join b in new List( context2.TheB )
on ---

But what if you'd like to have it executed on the server side? At first I thought that it should be obvious - while you cannot refer to two different contexts, you can of course use linked servers / synonyms mechanism built into the SQL Server 2005.



This however turned out to be impossible - for an unknown reason, probably a bug, sqlmetal does not include synonyms in the generated model. And because VS uses internally the same mechanism used in sqlmetal, the designer is not a big help also.



But what if you generate the missing part of the model by hand? Well, it seems that it does the trick. You just


generate the model for the main database

generate models for databases which contain tables linked from within the main database

trim these generated models (usually you do not create synonyms for the WHOLE database but rather for selected tables)

change the namespace and the class name of all generated classes to the same names


That's it. You have a single model which spans several files generated independently but it does not matter as all files contain partial definition of the same class.



BTW. The lack of the on-demand synchronization between the relational database schema and the dbml definition is kind of mockery to me.

Tuesday, February 5, 2013

Dynamics CRM 2011 - The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter

A weird error I faced when trying to RetrieveMultiple, adding range of GUID as condition values.


condition.Values.AddRange(myListOfGuid);

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter bla bla Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType


Solution was to change the guids to string


condition.Values.AddRange((from a in myListOfGuid select a.ToString()).ToArray());