Quantcast
Channel: Platform – C# City
Browsing all 16 articles
Browse latest View live

Using Enumerations as Bit Flags

Enumerations are great. Bit flags are also great. How can we combine these two together? That is, we want to do something like: enum Fruits { Apple, Pear, Mango, Grapes } Fruits f = Fruits.Apple |...

View Article



Running Windows Services in Visual Studio

Have you ever wanted to run a Windows service, without installing it, through Visual Studio? It’s actually not that hard to do this. This is useful in cases where you have a component which is a...

View Article

DriveInfo: Total vs. Available Free Space

If you’re curious about how query a drive and find out how much free space is left on it, in C#, there’s a conveniant DriveInfo class which exposes two properties for your usage: TotalFreeSpace and...

View Article

Writing Automated Performance Tests

I recently found out how easy it is to see how much total RAM your .NET app uses: `GC.GetTotalMemory(false)`. This gives you a simple total number of bytes that your app is using. Throwing this into...

View Article

Deserializing to Dynamic with RestSharp

RestSharp is awesome. Go try it. I highly recommend it (it’s overall less code and simpler than WCF, at any rate). Services may or may not provide a well-defined list of fields to you, the consumer,...

View Article


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

I ran into this seemingly innocuous error in my MVC4 app: Uncaught TypeError: Object [object Object] has no method 'autocomplete' Googling mostly resulted in “you have multiple versions of jQuery...

View Article

From C# Ruby and Back Again, via IronRuby

Note: This is the first of two articles on integrating C# and scripting languages. You can read the second part (on Javascript) here. I recently created an engine (I know, I know) to create text-based...

View Article

From C# To Javascript and Back Again, Via ClearScript

Note: This is the second of two articles on integrating C# and scripting languages. You can read the second part (for Ruby) here. I recently created an engine (I know, I know) to create text-based...

View Article


Manually Rolling Back a TransactionScope

The standard way to manage exceptions in ASP.NET (and by extension, MVC) web applications is to use the System.Transactions.TransactionScope class. It contains some useful properties: Auto Transaction...

View Article


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

View Article

Adding Forms Authentication to Web API

When you create a new Web API project, it grafts the API onto the existing web project. This can prove sub-optimal in cases where you want everything (including Forms authentication) to call into the...

View Article

Running FluentMigrator Migrations at Runtime

FluentMigrator’s Migrations Runners wiki page doesn’t mention any way of running migrations through code. Why might you want to do this? Because your application is in the hands of users, or ops teams,...

View Article

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

View Article


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

In a previous post, we talked about adding forms authentication to an ASP.NET project backed by Web API. One of the caveats of this setup is that if you apply the [Authorize] attribute to a controller...

View Article

How to Subclass .NET Classes from IronPython

IronPython is awesome. The recent revival of the new IronPython 3 project caused me to look again at IronPython (2.7). What if you created a base class in .NET and you want to subclass it in your...

View Article


Consuming RabbitMQ Messages in ASP.NET MVC

TLDR: You want to set up RabbitMQ in an ASP.NET process to persistently consume messages, and do something (like dump them to a database). This has to be independent of the life-cycle of an ASP.NET/MVC...

View Article
Browsing all 16 articles
Browse latest View live




Latest Images