codehelper.net

  • About

  • Unit Testing an ASP.NET MVC 4 Controller using MS Test, Rhino Mocks, AutoMapper and Dependency Injection

    I decided to put together a demo project to showcase unit testing an ASP.NET MVC controller. The MVC controller is part of a much larger n-tier solution that stores data in SQL Server, uses Entity Framework, has a data layer using the Repository and Unit of Work patterns, and a service layer on top, but […]

    April 26, 2013
  • ASP.NET MVC3 Using Code First Entity Framework Without Database Generation

    Note that this works just as well with MVC4 as it does MVC3. So, when is Code First not Code First? It is possible, even recommended, to use ‘code first’ techniques even when you are not generating the database from the code. This is hinted at in the Creating an Entity Framework Data Model for […]

    April 30, 2012
  • Extract the first N words from a string with C#

    This code will return the first 5 words, change the number in the regular expression as needed:

    December 16, 2011
  • Streaming Files for more Secure Downloads in ASP.NET

    If you just have a link to a file on your web site then you maybe leaving yourself open to other sites linking to the same files thereby giving their users the benefit of content without any hit on their bandwidth. It will also give clues to your site structure that can only be of […]

    March 23, 2011
  • Using the Entity Framework and the ObjectDataSource: Custom Paging

    Readers maybe familiar with the Entity Framework (EF) tutorials on the asp.net web site (http://www.asp.net/entity-framework/tutorials). The latest addition to the series “Continuing with the Entity Framework” is an excellent tutorial on using version 4 of the Entity Framework in a web forms application with the ObjectDataSource control. However, at present there is one omission that […]

    February 8, 2011
  • Using data from Entity Framework 2 to fill a 2010 local SSRS report in ASP.NET

    When you design a local SSRS report you are forced to use a Dataset as part of the design process, however, this does not mean that you have to keep the dependancy on a dataset or even retain the dataset in your project once you have completed the design. Simply use code similar to the […]

    November 23, 2010
  • Setting SSRS Report Parameters from ASP.NET C# Code

    It is sometimes necessary to customise SSRS (SQL Server Reporting Services) reports at runtime and one way of achieving this is through the use of report parameters. One reason for doing this might be to customise the report title, column headers, currency, number formats and date formats based on the user’s language settings.

    November 22, 2010
  • Back Button issue after Logout in ASP.NET

    This is the code most of us would normally use when logging out a user: FormsAuthentication.SignOut(); FormsAuthentication.RedirectToLoginPage(); A frequent problem is that after a user logs out of their application using this code or similar, if they then use the back button they are presented with pages from the application without having to login. The […]

    May 18, 2010
  • Preventing a User From Having Multiple Concurrent Sessions

    This article is largely based on information learned within the book “Professional ASP.NET 3.5 Security, Membership, and Role Management with C# and VB” by Bilal Haidar. A common question asked regarding ASP.NET is how can you prevent a user logging on more than once at the same time. Unfortunately, the nature of ASP.NET means that […]

    May 17, 2010
←Newer Posts

codehelper.net

Proudly powered by WordPress