How can I implement a theme from bootswatch or wrapbootstrap in an MVC 5 project?

The steps to apply a theme are fairly simple. To really understand how everything works together, you’ll need to understand what the ASP.NET MVC 5 template is providing out of the box and how you can customize it for your needs. Note: If you have a basic understanding of how the MVC 5 template works, … Read more

ASP MVC: When is IController Dispose() called?

Dispose is called after the view is rendered, always. The view is rendered in the call to ActionResult.ExecuteResult. That’s called (indirectly) by ControllerActionInvoker.InvokeAction, which is in turn called by ControllerBase.ExecuteCore. Since the controller is in the call stack when the view is rendered, it cannot be disposed then.

Creating a Service Layer for my MVC application?

I usually use a Service Layer when developing ASP.NET MVC application. It is similar to the Service Layer Pattern that Martin Fowler discusses in Patterns of Enterprise Application Architecture. It encapsulates your business logic and make the controllers pretty thin. Basically the controllers use the service layer to get the domain models that are then … Read more

TempData keep() vs peek()

When an object in a TempDataDictionary is read, it will be marked for deletion at the end of that request. That means if you put something on TempData like TempData[“value”] = “someValueForNextRequest”; And on another request you access it, the value will be there but as soon as you read it, the value will be … Read more

Set disable attribute based on a condition for Html.TextBoxFor

The valid way is: disabled=”disabled” Browsers also might accept disabled=”” but I would recommend you the first approach. Now this being said I would recommend you writing a custom HTML helper in order to encapsulate this disabling functionality into a reusable piece of code: using System; using System.Linq.Expressions; using System.Web; using System.Web.Mvc; using System.Web.Mvc.Html; using … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)