Skip to content

saYRam/SampleMvcWebApp

 
 

Repository files navigation

SampleMvcWebApp

SampleMvcWebApp is a ASP.NET MVC5 web site designed to show number of useful methods for building enterprise grade web applications using ASP.NET MVC5 and Entity Framework 6. The code for this sample MVC web application, and the associated GenericServices Framework are both an open source project by Jon Smith under the MIT licence.

This code is available as a live web site which includes explanations of the code - see an example of this on the Posts code explanation page.

The GenericService Framework is available on GitHub and soon via NuGet (when the release is stable).

The specific features in this code are:

1. Simple, but robust database services

Database accesses are normally a big part of enterprise systems build with APS.NET MVC. However, my experience is that creating these services in a robust and comprehensive form can lead to a lot of repetative code that does the same thing, but for different data. My aim has been to produce a generic framework that handles most of the cases, and is easily extensible when special handling is required. Examples of there use on this web site are:

2. Adding Sql Security support to Entity Framework

SQL Server and Azure SQL databases have a range of data security features. This is provided by a non-Open Source library called GenericSecurity that links into the GenericServices library and this sample mvc web site to provide Sql Security support in this example site.

  • A new SecureSampleWebAppDb causes sql logins to be used to set what users can access.
  • (In this demo you can select different users with different access rights from a drop down box).
  • There is a separate Course/Attendee part of the database that provides examples
  • Full explanations of the access rights and how this feature was implemented are given.

3. Handling long running tasks

Having long running tasks on a web site without feedback is not what users expect. My mathematic modelling applications have a lot of long running tasks so I have developed specific code for displaying progress messages and allowing the user to cancel a task etc.

4. Use of Dependency Injection

The GenericService framework is designed specifically to work with Dependency Injection (DI). DI is used throughout this web site, but specific examples are:

  • Inserting the required services into a controller by action parameter injection.
  • DI is also used for creating the GenericService etc. See Code Explanation for more information.

Note that the SampleMvcWebApp uses AutoFac dependency injection framework, but the framework allows you to replace AutoFac with your own favourite DI tool.

About

A Sample MVC5 web application to show various approaches to common issues.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • C# 69.8%
  • JavaScript 28.0%
  • Smalltalk 1.3%
  • Other 0.9%