Blog

Convert any List to valid jqGrid Json Object.

By David EspinoJquery UI controls are actually very useful on many web projects and jqGrid is an excellent example. This is a really handy control that can help us to render our list of objects using Ajax calls. How to fill the jqGrid? The jqGrid needs a json object with a particular structure. This is an example of the json object used to fill a jqGrid. {"page":1,"total":100000,"records":1000000,"rows":[{"id":"1","cell":["1","VINET","1996/07/04","32.3800","Vins et alcools Chevalier"]}, {"id":"2","cell":["2","TOMSP",...

MVC 3 and Model Binding

By Carlos MartinezThe System.Web.Mvc namespace contains a class named DefaultModelBinder, the application object in MVC uses an instance of this class in order to binding all the values inside a post to a given model so it can be passed to an action. For normal scenarios no code is needed for these purposes.   When needed, a custom binder can be used in order to implement complex binding logic to a specific action or type. This new custom binder should implement the IModelBinder interface; this binder could be specified in the parameter definition of the post action for example:   [HttpPost] public ActionResult Index([ModelBinder(typeof(CustomModelBinder))] CustomModel model)   I...

How to implement custom validation logic using attributes in MVC3

By Carlos Martinez A common (and very recommended) practice when working with model validation in MVC3 is to decorate the model that will be sent to the view with validation attributes.  In order to do this MVC3 has several validation attributes ready to use for this scenarios such as: ·         DataTypeAttribute ·         RangeAttribute ·         RegularExpressionAttribute ·         RequiredAttribute An easy way to implement custom validation is to create attributes that inherits the ValidationAttribute  class and add logic to the IsValid Method. Adding code in this point will add server validations to the model (once the values are filled in the model throu a ModelBinder this vali...

Deploying a Message Queue WCF Service

By David E.  The following guide was the created installing MSQueue and configuring a WCF using a Windows 7 OS. 1.       Verify IIS is installed on the server machine where the WCF is going to be hosted.   2.       Install MS Queue by following the instructions specified on this link:   http://msdn.microsoft.com/en-us/library/aa967729.aspx            3.    Install or verify the following Windows Features : 4.       Verify the following services are running: a.       Message Queuing b.      Net.Msmq Listener Adapter c.       Windows Process Activation Service   5.       Create a Web application inside IIS. For this example, the application name used is FGMQService. The ap...

Asp.net 4.0: To allow capture of html tags inside a textbox

By David E. On rare occasions inside our web application it is necessary to allow the user to enter some content in html format. In previous versions this was possible, and it was the responsibility of the programmer to validate those labels to prevent a user from entering malicious code to our application. With ASP.net 4.0 the information will now be validated automatically. If a user tries to add html tags to a web application, the result will be an exception. This validation feature can be disabled with a simple statement of the web.config file. The first thing to do in Visual Studio 2010 is to create a new web application, then we can add a new web form and then create the basic ...

Synchronous and Asynchronous Validations using the Silverlight 4.0 and the MVVM pattern

By David Espino. In every application that we develop, it is always an excellent practice to validate the entry data of an opt-in form. In common web applications, Visual Studio provides several mechanisms and controls to perform such validations. In the case of Silverlight 4.0 we can find some existing interfaces that allow us to do such validations when developing applications using the MVVM pattern. Introduction to the MVVM pattern. This design pattern allows applications to divide them into separate layers and provides additional benefits such as implicit validation, ease of including unit tests and an increase in the reuse of components. The pattern defines three main parts, th...

How to Handle the WCF Error on Silverlight

By David Espino. When sending a call to a WCF service from a Silverlight application and the service returns an error, the Silverlight client backs up only a very generic error: The remote server returns an error: NotFound This message does not help to know the exact error neither for the user nor the developer. Even more, it is necessary for more security to make a division of the error information: one message for the user and one detailed message for the system administrator or developer. The first part of the error dedicated to the application administrator consists on writing the exception that the code generates on a detailed way. There are a lot of tools that allows tomake th...

ASP.NET 4.0, MVC and request validation

By Alejandro Villarreal If you’ve ever dealt with the front-end part of application development in ASP.NET, you might have encountered the following error at some point: A potentially dangerous Request.QueryString value was detected from the client This happens when the user submits a value (either in a form or in the query string) that the ASP.NET Framework considers dangerous, in the sense that it might be an HTML/script injection attack. Sometimes it is necessary to turn that feature off (see here and here on how to do it). It might be the case that you expect the user to provide valid XML/HTML, and thus you don’t want the Framework to abort the request with an Exception. As explai...

Getting Started with PowerShell Remoting

By Irvin Gomez   As a software engineer, more often than not I find myself writing code in C#, and things tend to be pretty neat inside Visual Studio. However, when we need to deploy our new application to the servers where the application will be hosted, the number of Remote Desktop sessions we require can be overwhelming. Here is where PowerShell Remoting comes to the rescue. Basically it allows a client machine to connect to another machine and then you can run PowerShell commands and scripts typing from the client. Think of Telnet on Unix machines. Remoting is a feature introduced on PowerShell v2.0 and basically will let you run any PowerShell command or script (like deployment...

WCF service in IIS with multiple host-headers

By Alejandro Villarreal Hosting WCF services in IIS is usually a very straightforward process with no weird configuration settings or obscure errors. You create a site in IIS, publish your service in the site’s folder, and you’re ready to go. However, things start to get a bit complicated in more advanced scenarios like the one I encountered some days ago: if your site in IIS answers to multiple host-headers, then when you try to access the service through a web browser, instead of seeing the usual page with the service description you will receive a screen indicating a Runtime Error, and you should be able to find an Error entry in Window’s Event Viewer (under “Windows Logs”/Applicatio...
 Next >>