Blog

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 ...

ValueConverters on Silverlight

By David Espino On several occasions when we want to present screen data on our application, it is necessary to give to it a particular format when it is showed on the screen. The ValueConvertes inside a Silverlight application help us to accomplish this objective. One class of IvalueConverted that is implemented modifies the data that flow to the controls when a Binding is made. For this example we create a Silverlight application with its own Website. First, we need a class that is going to help us with our data entity and it’s going to storage the basic data of an order. publicclassOrder     { publicintOrderNumber { get; set; } publicint Items { get; set; } publicdouble Total...

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...

Quirks of Distributed Transactions (MSDTC) and SQL Server

By Alejandro Villarreal Distributed transactions can be of great help when dealing with complex operations that must be atomic across servers, but then again for their very nature –distributed– they can be hard to debug when something fails. A good example of this is an error I encountered recently. Here’s a bit of background: We have a Web Application hosted in Server01 sending messages to a WCF Service through an MSMQ endpoint (we’re using transactional queues to leverage their reliability), and this Service saves the content of the messages it receives in a SQL Server database hosted in a remote server (Server02). The queue in Server01 plus the database in Server02 make this a distri...

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...