Category Archives: Web

ASP.net and other C# web-application stuff

Consuming RabbitMQ Messages in ASP.NET MVC

You can create an ASP.NET MVC site that consumes RabbitMQ messages with a persistent connection; here’s how (static variables, no using statements). Continue reading

Posted in Libraries, Web | Tagged , | Leave a comment

Changing the Login URL from login.aspx on ASP.NET MVC with Forms Authentication

When you enable forms authentication in an ASP.NET MVC5 web application, by default, it redirects unauthenticated requests to ~/login.aspx. You can specify web.config configuration (authentication tag, forms sub-tag, loginUrl property) to change this. Continue reading

Posted in Libraries, Web | Tagged | Leave a comment

Authenticating Against Web API from ASP.NET MVC

In a previous post, we talked about setting up ASP.NET MVC and Web API to accept forms authentication. With this structure in place, your MVC front-end can make Web API calls. The question is, how do you authenticate? What cookies … Continue reading

Posted in Libraries, Web | Tagged , | Leave a comment

Running FluentMigrator Migrations at Runtime

You can run FluentMigrator migrations at runtime, through code. You need to reference the `FluentMigrator.Runner` package, and with some sample code, you can easily check the current/latest version and update to the latest (or to a specific) version. Continue reading

Posted in Libraries, Web, Wndows Forms | Tagged , | Leave a comment

Adding Forms Authentication to Web API

Web API projects don’t ship with external (forms) authentication, but it’s not hard to graft them on. Using the MVC project code, we can easily add forms authentication to the Web API. Continue reading

Posted in Core .NET, Web | Tagged , | Leave a comment

Mocking Base Class Methods with Moq

Moq does allow you to mock base class methods, via the use of the Moq.Protected namespace. You can read about it here. Imagine you have the following scenario: class Animal { private int timesTalked = 0; public void Talk() { … Continue reading

Posted in Libraries, Web, Wndows Forms, WPF | Tagged | Leave a comment

Manually Rolling Back a TransactionScope

How do you rollback a TransactionScope instance? Well, with Dispose, oddly enough. Continue reading

Posted in Core .NET, Web | Tagged | Leave a comment

ASP.NET MVC 4: Uncaught TypeError: Object [object Object] has no method ‘autocomplete’

How do you get jQuery’s autocomplete to run in ASP.NET MVC4 websites? Upgrade to at least jQuery 1.8, render the jQuery UI scripts, render the jQuery UI CSS, and you should be good to go. Continue reading

Posted in Libraries, Web | Tagged | 1 Comment

Deserializing to Dynamic with RestSharp

You can use JSON.NET to convert any RestSharp service response to a list of dynamic instances; you just need a bit of plumbing code to do it. Continue reading

Posted in Libraries, Silverlight, Web, Wndows Forms, WPF | Tagged , | 6 Comments

Using Enumerations as Bit Flags

You can use enumerations as bit flags. The FlagsAttribute is optional; more importantly, you need to assign powers of 2^n to the enum’s values. Depending on the .NET version, checking can be easy (.HasFlag) or hard (bitwise AND operation) Continue reading

Posted in Core .NET, Silverlight, Web, Wndows Forms, WPF | Tagged , | Leave a comment