Archive for the 'aspmvc' Category

Disable browser cache in asp mvc

Friday, July 29th, 2011

Here is a simple trick on how to disable browser cache in your asp .net mvc application with an attribute. If you have a base controller just add this to your base and all your request would have Pragma No-Cache ?View Code CSHARP1 2 3 4 5 6 7 8 9 10 11 12 13 [...]

Share

Enable https on ASP.NET MVC 2 & 3, through Filters and web.config

Tuesday, July 26th, 2011

To enable SSL on asp.net mvc, one can use the [RequireHttps] attribute on the base controller if you are using a base controller ?View Code CSHARP1 2 [RequireHttps] public class BaseController: Controller But what if you want to give an option to the installer or the client to enable it in web.config, the easy way [...]

Share

My talk on WatiN , SpecFlow, BDD, Code and additional material

Saturday, April 2nd, 2011

Thanks to everyone who came out for the Ottawa .Net Community talk yesterday, I had a blast. I would like to thank everyone who came out for the talk. Here is my presentation WatiN – Web Application Testing on Prezi You can find the code on github https://github.com/taswar/ODNC-WatiN-And-SpecFlow-Demo-Code Additional Resources Here are some additional information [...]

Share

ASP MVC, Jquery modifying a select drop down with Json data

Thursday, November 18th, 2010

Was coding some new functionality and though I would post this, so that others can find it helpful. Lets say you have a form that has a checkbox that will update the select dropdown box with different values, when the checkbox is clicked. Something like the UI below. Your html code might look like ?View [...]

Share

Stubbing out ServiceLocator for unit testing

Wednesday, June 30th, 2010

There are certainly many ways to stub out dependency, using constructor injection, etc etc. Here is one way to quickly stub out ServiceLocator rather than implementing ServiceLocatorStub. Lets say you have code that uses a helper and the dependency is not quite the responsibility of that object but its the sub object that uses it. [...]

Share

Json A circular reference was detected while serializing an object of type … in my asp mvc app

Wednesday, June 9th, 2010

I found this weird error when I was testing a no trivial test case in my app and was not able to find out what was wrong with it. It appears like a Json error in my asp mvc app, although the stack really doesn’t help ?View Code CSHARP1 2 3 4 5 6 7 [...]

Share

ASP .NET MVC2 Changes: GetControllerInstance & DataAnnotationsModelBinder

Tuesday, March 30th, 2010

So was in the process of updating my mvc app, there is a tool that does it for you and also a manual way . But once you have updated there are also 2 more changes that you may need if you are using IoC or DataAnnotations. First you will need to change the method [...]

Share

SparkViewEngine: Highlight Table Alt Row

Monday, March 29th, 2010

Here is how one highlights an alt row with spark, quite clean I tell you. Assuming you have a css that like below. ?View Code CSS1 2 3 4 5 6 tr.alt { text-align: left; padding: 2px; border: 1px solid #000; background: #ADDFFF; } And in your template you will call it like this. ?View [...]

Share

Url Helper Extension Method for ASP MVC in form tags when using IIS 6

Monday, December 21st, 2009

So I was going through some code of codebettercanvas and found it interesting of Karl Seguin using Html Helper extension for his form tags, which has its elegance. e.g ?View Code HTML1 <form id="login" action="!{Html.LinkTo<HomeController>(c => c.Login()) }" method="post"> Basically it calls an extension method called LinkTo with a generic controller and a lamda for [...]

Share