Geeks With Blogs

News profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers

Donate Bitcoins

Check out Elapser from T3rse!
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.

Programming and Learning from SD MVC ASP.Net MVC
Quick Guide to setup a MVC project for Unit Testing
A barrier to getting into writing executable tests (Unit Tests, integration tests, automated UI tests, etc) with some people I work with, is not knowing how to get started. I believe the desire and the recognition of the value and importance of this testing is growing, but I want to help people get over that hump. Read the MSDN Unit Testing MVC article. consider splitting controllers into a different project as suggested Don’t put your data access code inside the Controller methods, use a data layer/object. ......

Posted On Thursday, September 25, 2014 9:18 PM

MVC OnActionExecuting to Redirect
I recently had the following requirements in an MVC application: Given a new user that still has the default password When they first login Then the user must change their password and optionally provide contact information I found that I can override the OnActionExecuting method in a BaseController class.public class BaseController : Controller { [Inject] public ISessionManager SessionManager { get; set; } protected override void OnActionExecuting(ActionExe... filterContext) { // call ......

Posted On Tuesday, August 12, 2014 3:59 PM

Steps to Get MVC running with Ninject
enable package restore on solution Nuget Ninject.MVC3 (pre-release available?) * adds Ninject, Ninject.Web.Common, Ninject.Web.Mvc * App_Start/NinjectWebCommon.cs -> has WebActivator.PreApplication... attribute -> runs at startup add interface and class for testing (IBikeManager and BikeManager) add controller constructor to HomeController that takes in the interface - run website => Error "Error activating IBikeManager No matching bindings are available, and the type is not self-bindable. ......

Posted On Wednesday, November 20, 2013 10:46 AM

When to set ws2007FederationHttpBinding establishSecurityContext to false
Turning the establishSecurityContext off (it’s on by default) was recommended in the IAC course on Pluralsight by Dominick Baier in the Security Best Practices module, State Management when making lots of short calls. “Other protocols like the WS 2007 Federation HttpBinding, they support state and unfortunately it’s turned on by default…. [uses] WS-Secure Conversation which is kind of heavy handed. It is quite complex as well and it has some performance implications.” ~ Pluralsight video http://www.code-magazine.co... ......

Posted On Wednesday, June 12, 2013 11:26 AM

Knockout Js and External MVC cshtml templates
I can pass the name of the template to the controller like this (/Templates/KnockoutTemplat... where 'radial' is the name of a view (radial.cshtml), return a partial view of that name and have Knockout put it in the template block. My Controller: public class TemplatesController : Controller{ public TemplatesViewModel viewModel { get; set; } public ActionResult KnockoutTemplate(string templateName, int? id) { this.viewModel.Id = id; return PartialView(templateName.Re... ......

Posted On Friday, August 17, 2012 8:18 AM

Scripts not loading with ScriptBundles?
We upgraded a javascript library and pointed to the *.min.js files in our MVC4 application. They weren't getting downloaded and were not in the source code when running in debug="true", but worked in debug="false".

The lesson is to remove .min from your js files or the ScriptBundle doesn't return them for downloading.
bundles.Add(new ScriptBundle("~/bundles/x").Include(
                "~/Scripts/x*"));

Posted On Thursday, August 16, 2012 2:30 PM

Faking the WebApi User
I needed to unit test a WebAPI call in my MVC 4 application that checks the user's role. I'm doing this in my MVC controllers with the following code using FakeItEasy (I should do a post on that sometime): this.UserPrincipalFake = A.Fake<IPrincipal>(); A.CallTo(() => this.UserPrincipalFake.Iden... A.CallTo(() => this.UserPrincipalFake.Iden... this.HttpContextBaseFake = A.Fake<HttpContextBase&g... this.HttpContextBaseFake.User ......

Posted On Wednesday, June 5, 2013 10:29 AM

MVC Performance Tip
MVC can work with .cshtml or .aspx pages (you can mix Web Forms and Razor views in the One ASP.Net that Scott Hanselman talks about). This means MVC will search for a view with endings of .aspx, .ascx, .cshtml, .vbcshtml, in the Controller directory (if you have a HomeController, then it it would look in Views/Home, then Views/Shared). If you aren’t using aspx pages it’s doing extra work it doesn’t need to do. See Dave Ward’s post on the importance of using debug=false and Marcin Doboz’s post on ......

Posted On Friday, May 31, 2013 8:10 AM

Pre-Compiling your MVC Views
One part of MVC Views that can cause problems is that the cshtml can cause run-time errors. This can lead to bugs in Production or found by QA that could be avoided if it was built when you build the project. Pre-compiling can be turned on to avoid those problems. You add this in the project file of your web application, by setting the <MvCBuildViews>true&l... in the .csproj. See http://www.dotnetcurry.com/... for more details. Another reason to pre-compile ......

Posted On Tuesday, May 28, 2013 12:28 PM

Uncaught SyntaxError: Unexpected token u. file JavaScript Error in MVC
I was getting a JavaScript error that pointed to line number 1 of my MVC page. I have a form on the page and expected the Unobtrusive Validation to work with the Data Annotations. It took me a while to realize the validation messages weren't showing. After I while I found that I was missing the @Html.ValidationMessageFor(m => m.Name). Adding that for each field fixed it. My password reset with token example. I was missing line 12 and 17. 1: @using (Html.BeginForm("PasswordRe... "Home")) 2: { ......

Posted On Monday, May 20, 2013 1:45 PM

Copyright © Aligned | Powered by: GeeksWithBlogs.net | Join free