Showing all posts tagged: 'ASP.NET'

A 24-post collection

My thoughts on TechEd 2014 announcements

Are you following this? Are you watching the videos? I think Channel9, the official Microsoft media outlet, died from overwhelming demand. The cynics may say that this is because of technical issues, however, I say that this is due to a highly demanding audience :). If you have been unable to watch the live stream, rest assured that all recordings will be available online soon (usually withing 48hrs). It's only been a month since the //Build event where Microsoft announced a host of new features, open sourced their new Roslyn compiler, and brought the mobile, desktop and gaming platforms together under …[read more]


Getting Json data using jQuery and .ASMX web services.

If you still have the misfortune to work with asmx services on your project, you may want to know how to easily retrieve json data from an asmx method. The differences between asmx and WCF have been aalyze[d b]efore here and here. Return a simple string as json response:### Your asmx page code#### [WebService(Namespace = "http://contoso.com/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]System.Web.Services.WebService [ScriptService] public class services :WebService { [WebMethod(CacheDuration = 60)] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetGreeting() { return "hello world" } } Your javascript code#### …. code omitted … var getGreeting = function() { var …[read more]


Processing payments on your site using Stripe and C#

Update: The current example of processing payments is NOT PCI-compliant as the card details are posted to the server. A better approach is to use the Stripe.js to generate the token and then process the payment - thanks to Christian Bryant for raising it in the comments. Take me to the PCI-Compliant option now As a web developer you are bound to have come across a requirement to implement some form of online payment processing for a site. This can be achieved using any number of third party providers such as Sage or PayPal etc. Although most of these …[read more]


Resolving “HttpContextWrapper is not serializable” errors after upgrading Glimpse.

If you are doing any ASP.NET development and not using Glimpse you are seriously missing out. It helps is so many ways to troubleshoot and improve performance that I cannot believe how I’ve done any web development without in the past. I’m really grateful for the work that it has been done by the developers. However, today I decided to update all the NuGet packages I thought they were safe and as you would have guessed it, the update broke my MVC4 website. A simple MVC website will probably not come across this issue, but I have …[read more]


HTML5 Drag and Drop file upload with preview using jQuery and MVC 4

With the advent of HTML5 and its wide adoption by all major browsers, web developers now have a new arsenal in their hands for implementing powerful file upload functionality on their website. In this tutorial we will see how to implement this using the FileDrop jQuery plugin and an MVC controller to receive and store the uploaded files in a repository on the server. First create a new MVC 4 website in Visual Studio. An existing website can also be used.  Create a new blank view and name it “UploadFiles”. You should be able to navigate to the page using …[read more]


NLog with SQL Server and MVC 4

NLog is a great open-source logging tool that allows developers to easily and efficiently implement custom logging. Nlog can be configured to log to a number of targets, but on this tutorial we will be looking at logging to the database. First you need to add NLog to your MVC website. Bring up the Nuget package manager and search for NLog. Add the following packages: NLog NLog Schema for Intellisense NLog configuration NLog for Extended Profile This will add the necessary dlls and config files for use later. Once the installation is complete, you should see the following file at …[read more]


jQuery UI Autocomplete with jSON in MVC 4

jQueryUi has an autocomplete plugin that allows developers to turn any standard text box to turn any standard textbox to an autocomplete search box. In this case we will try to implement this in the simplest way possible using a web service as the data source. First of all, create a standard MVC 4 project. This will be used to test our functionality, however any existing website can be used for the same purpose. If you are not already referencing the jQuery and jQuery UI libraries in your _layout.cshtml, add them. You can either add them directly in your …[read more]


Using an Smtp client in ASP.NET MVC 4 and C#

If you need to send emails from your website, the .NET framework provides a very handy library for this:  System.Net.Mail. The configuration and testing is pretty straightforward so let’s get started. Firstly we need to configure the SMTP settings in the web.config. Under the <configuration> element add the following config section: <system.net> <mailSettings> <!-- Method#1: Send emails over the network --> <smtp deliveryMethod="Network" from="[email protected]"> <network host="your_smpt_server_dns_name" userName="your_smpt_server_username" password="your_smpt_ …[read more]