Sunday, Apr 25th, 2010 by karlz |
1 Comments
Filed under:
Technology | Tags:
ASP.NET,
MVC,
Unit Testing,
VS 2010
Technorati Tags: Unit Testing,ASP.NET,MVC,VS 2010
Story: I want to write a unit test to ensure that the Authorize attribute is applied to a controller ActionResult or ViewResult so that security is tested.
Here is the test:
Unit Test
[TestMethod]
public void PreviousSiteUserConversion_Authorization_Attributes_Have_Been_Applied()
{
// Arrange
MethodInfo varietalMethod = typeof(AdminController).GetMethod("PreviousSiteUserConversion", new Type[] { });
// Act
var attributes = varietalMethod.GetCustomAttributes(typeof(AuthorizeAttribute), true);
// Assert
Assert.IsNotNull(attributes);
Assert.AreEqual(1, attributes.Length);
var authAttribute = (AuthorizeAttribute)attributes[0];
string[] [...]
Saturday, Apr 24th, 2010 by karlz |
1 Comments
Filed under:
Technology | Tags:
.NET 4.0,
ASP.NET,
Hosting,
MVC,
VS 2010
Technorati Tags: .NET 4.0,Hosting,ASP.NET
I’ve used CrystalTech for years. They seemed to be falling behind a bit when I started to work with the MVC (Model-View-Controller) pattern. That works MUCH better with IIS 7 than with IIS 6, but CrystalTech only had IIS 6 servers.
That’s all changed!
I now have no excuses for not upgrading my sites [...]
Wednesday, Mar 3rd, 2010 by karlz |
0 Comments
Filed under:
Technology | Tags:
ASP.NET,
Code Analysis,
MVC,
Unit Testing
Technorati Tags: ASP.NET,MVC,Code Analysis,Unit Testing
This shows my initial setup of an MVC 2 RC 2 application. Using Visual Studio 2010 RC I selected File –> New –> Project… then under Visual C#, Web, I selected the ASP.NET MVC 2 Web Application.
Then when I click OK I get the following dialog. Since I’m a very [...]
Saturday, Feb 27th, 2010 by karlz |
0 Comments
Filed under:
Technology | Tags:
ASP.NET,
Moq,
MVC,
TDD,
Unit Testing
Technorati Tags: MVC,TDD,Mock,Moq
I strive to use TDD (Test Driven Development) so not having unit tests drives me crazy. I was so pleased to run across this post http://ox.no/posts/mocking-htmlhelper-in-aspnet-mvc-rc1-using-moq making it easy for me to unit test the Html Helper.
But then I downloaded the MVC 2 RC 2 and all my unit tests for HtmlHelper broke! [...]
Saturday, Feb 6th, 2010 by karlz |
0 Comments
Filed under:
Technology | Tags:
ASP.NET,
MVC,
VS 2010
Technorati Tags: MVC,ASP.NET,VS 2010
The primary MVC (Model-View-Controller) application that I’m working on is called KarlZMvc resulting in a dll called KarlZMvc.dll. To get the version output on my Site.Master page I need to include the following line:
Code Snippet
<%= typeof(KarlZMvc.MvcApplication).Assembly.GetName().Version.ToString() %>
I tried all sorts of combinations with the GetExecutingAssembly, or calling, etc. But none seemed to [...]
Friday, Feb 5th, 2010 by karlz |
0 Comments
Filed under:
Technology | Tags:
ASP.NET,
Globalization,
MVC
Technorati Tags: MVC,Globalization,ASP.NET
Headline: Putting the following code in the web config (at least for an ASP.NET MVC app) will cause your pages to honor the user’s browser settings.
Code Snippet
<!–If culture and uiCulture are set to auto, ASP.NET can set the UI culture and culture for a Web page automatically, based on the values that are [...]
Thursday, Jan 28th, 2010 by karlz |
1 Comments
Filed under:
Technology | Tags:
ASP.NET,
MVC
Technorati Tags: MVC,ASP.NET
Headline: Only use a colon as a separator when there is no other visible means of separation. Stated differently, “Stop using a colon between a label and a text box!”
Back in DOS (Disc Operating System) when there was no graphical user interface we needed a way to let the user know what the [...]
Sunday, Nov 29th, 2009 by karlz |
0 Comments
Filed under:
Technology | Tags:
ASP.NET
Technorati Tags: ASP.NET
Headline: Run “aspnet_regsql.exe”.
User Story: As a web developer I want to use the AspNetSqlProviders for my website using an SQL Server database so that I can more easily host the site.
Take 1:
I was excited about the new ASP.NET MVC 2 being in the beta for 2010. So I created a new site. I [...]
Saturday, Jun 27th, 2009 by karlz |
0 Comments
Filed under:
Technology | Tags:
ASP.NET,
EF,
MVC,
Unit Testing,
VS 2010
Ok… It wasn’t really that bad, but it did take some effort. Here was my objective: Now that MVC (ASP.NET Model-View-Controller) 1.1 has been released (not sure how I missed that) to work with Visual Studio 2010 and .NET 4.0 migrate my evolving website to use the .NET 4.0 beta.
I was able to get it [...]
Saturday, Jun 20th, 2009 by karlz |
1 Comments
Filed under:
Technology | Tags:
ASP.NET,
MVC
Headline: A very simple change to the DefaultModelBinder will allow you to use default validation capabilities in Microsoft’s MVC (Model-View-Controller) Framework far more effectively.
The Problem – Please show my model exceptions to the user!
As Steven Sanderson stated in his book, you want to have the validation for your model in an MVC application in the [...]