Tag | MVC Posts

In this article I'm going to demonstrate how to create a simple sign-up form using ASP.NET MVC 3. So basically in this demo you will learn the following: How to insert data to the database with Entity Framework How to validate the Form using Data Annotations How to Authenticate users after sign up using FormsAuthentication Note that before you continue reading this article be sure that you have the basic understanding about ASP.NET MVC in general. You can refer the following links below to learn ...
LDAP is not Active Directory, though Active Directory is LDAP. As someone who drinks the Microsoft Kool-Aid, I found myself using LDAP for something other than Active Directory and I thought I should share what I have found. The problem domain was to connect a new MVC application to an existing Sun One LDAP Store. First off, authenticating an MVC application using forms mode authentication and the Membership providers is straight forward. Start with the ASP.NET MVC 2 Web Application Template that ...
Doing more unit testing and I ran across this nice article on mocking up TempData. That’s great because tempdata is used a lot in controllers and you need a way to mock it for unit testing. Again, this code is in C#, so I will show you the vb version. http://weblogs.asp.net/left... Hres the StubTempDataHttpSessionState class: Imports System.Web.Mvc Imports System.Web ''' <summary> ''' HttpSessionState for TempData ...
I was working on unit testing today for an MVC application and needed to mock up the http context for an action method. I found this article that shows how to do this nicely. http://bradwilson.typepad.c... Yeah, I know, you can do this with rhino mock and others. But this works too. I converted this to VB so I could use it in the same project. Heres the vb code: Imports System.Collections.Specialized Imports System.Web Public Class ...
I'm running into some bizarre behavior with JavaScript in Mobile IE 6. I have an ASP.NET MVC 3 Web App, designed primarily for Mobile IE6 (WinMo 6.5 devices) I have 2 Session variables. The first one simply contains a "0" or "1" and I can access it by doing something like this in JavaScript: var lbType = '<%= HttpContext.Current.Session... %>'; I can use it, display it in an alert, whatever... that works, no problem. The other session variable is also a string, but is a bit longer (roughly ...
Much has been talked about the new release of ASP.NET MVC, i.e. MVC 3 and the new Razor syntax and the ability to simplify the development. Razor uses the @ prefix for switching between code and HTML and that kind of simplifies it when compared to using <%: symbol as with the case in MVC and ASPX engines. Here is a nice article from David Ebbo on how all of these fit together Not just that, Razor comes with a lot of goodies. The Helper classes simplify in doing some of the common tasks, doing ...
June the 23rd the Belgium user groups have another free event. It’s called the Community Day and this year they will celebrate their 5th anniversary! To celebrate this they invited some collegue-usergroups from across the border to speak there as well. Timmy Kokke from Sixin (http://www.sixin.nl) and myself will be there to talk about a number of items. I will be doing a talk on MVC 3 (not so interesting for regular readers of this blog) and a talk on Surface Development (which fits this blog more ...
You probably have already visited Channel 9, and if you have not I would recommend to definitely check it out. There are literally thousands of videos about development using Microsoft technologies (and more). You can watch the videos on the site using Silverlight player or you can use links on each video page for downloading. This usually works fine if you are interested in just one or a small number of videos, but it might become somewhat tedious if you want to download a bunch of them. I recently ...
At http://www.codeproject.com/... there is interesting article "DaST Concept: A simpler, smarter, and much more powerful alternative to Forms and MVC." Both MVP and MVC suffer from division of responsibility. If DaST is genuinely simpler then it is to be welcomed. The project somewhat surpisingly to my thinking is on Source Forge at https://sourceforge.net/pro... - I would have expected it to be on CodePlex. The project home page is at http://aspnetdast.sourcefor... ...
In this Issue: David Catuhe, Andrea Boschin, Kunal Chowdhury(-2-), Colin Eberhardt, Mike Ormond, Doug Rathbone, John Garland, Jesse Liberty, Mike Taulty, and Pete Brown. Above the Fold: Silverlight: "ItemsControl from scratch to your own controls" Andrea Boschin WP7: "Metro In Motion #5 – SandwichFlow" Colin Eberhardt Shoutouts: Alan Cruz sent me a link to his Social Network site he's developed in Silverlight... this is another 'sign yourself up' thing... I did it, nothing bad happened :) ... Alan ...

I had a great time presenting MVC 3 and the Web Platform at CMAP this week. Thanks to everyone who came out. The code samples and PowerPoint can be downloaded here.

NuGet (pronounced NewGet), is an open source .Net Package Management Tool compatible with Visual Studio 2010 both Express and Commercial Editions. This simple-yet-powerful tool offers a simple way for incorporating and managing .Net packages in Visual Studio 2010 projects. In leveraging NuGet, we get an intuitive user interface allowing the selection of available packages and an easy way to subsequently manage version upgrades or uninstalls for packages already installed via NuGet. I recently spoke ...

This Tuesday (May 3) I will be presenting MVC 3 and the Web Platform at CMAP. Details can be found here. Hope to see you there!

Join us for a special WebMatrix and ASP.NET MVC Web Camp you don’t want to miss. No matter your expertise in web development, these Web Camps are the perfect opportunity to get hands-on experience and 'unleash your coding genius'. Our interactive sessions will: Introduce ASP.NET Web Pages and WebMatrix; discuss possible uses of these Facilitate an in-depth discussion on when to migrate ASP.NET WebPages applications to ASP.NET MVC Explore new features of ASP.NET MVC 3 Take a dive deep into jQuery ...
Sometimes, the way that LINQ to Twitter materializes queries into entities isn’t immediately clear. It’s easy to get confused until you see the patterns or make a correlation between the Twitter API results and their representations as LINQ to Twitter entities. In this post, I’ll explain some of the logic behind the design of LINQ to Twitter entities and demonstrate an example of one of the more oddly designed entity types, Search. Note: They'll be talking about MVC3 during multiple sessions at Tech-Ed. ...
Well, this one was fun. So my mvc app was having trouble with javascript files. Seems like if I had more than one file linked in, that only the 1st was picked up. The tags looked like so: <script src="<%=Url.Content("~/S... type="text/javascript"/> After much scratching my hair out and trying different things, I figured it out. The problem is the />. You have to end the script tag like so with </script> and not the shortcut syntax: <script src="<%=Url.Content("~/S... ...
In this post I want to highlight how easy it is starting a MVC Project using NuGet and deploy it to AppHarbor. It is not much but it is fun. First you need to install Visual Studio 2010. Then, go to Tools –> Extension Manager. From the Online Galery install NuGet ( if you don’t already have it ). Make sure you also have ASP.NET MVC3 installed. Create a new MVC 3 Project. Add a Class Library project to the solution. Since you’ve added NuGet you have access to the Package Manager Console. I’m sure ...

This blog now lives here.

UPDATED 6 JAN 14 In last days I Installed MVC 3 update in my PC. Today I got chance to take a look on MVC 3. I create a sample project and see a kind of problem “Nuget is not installed or out of date”. For those people who have trouble like this. Go to tools > Extensions > uninstall the Nuget and installed the Nuget again. Now it will work fine. This problem happen in VWD 2010 Express sp1. For people’s information MVC3 come pre-installed in 2012 and then removed in 2013. Don’t worry MVC 3 project ...
When user trying to install MVC 3 using Microsoft Web Platform Installer they got the message that MVC 3 and some other component also installed successfully but whenever in the condition you trying to open WPI again that they show you a option for adding all those component who you installed last time that means that they not installed successfully or error not occurred in WPI but actually occurred. So How i can install MVC 3 when i got error 1603 or whenever my system unable to run the setup or ...
UPDATED 13 January 2013 This post is written at a time of Visual studio 2010. In Visual studio When you compile your project You compile every project under the same solution. For make fast resolution you can compile only the project that you are working on now. Exclude the project from debug which you currently not working on. Here is some great discussion on SO http://stackoverflow.com/qu... ...
Today I was working on the mvc app I am building for a customer. We need to send email from the app so I used the system.net.mail feature in .Net. As part of this, I need a Windows 7 smtp server. So I found the smtp4dev app on codeplex. I found it on this nice blog http://social.technet.micro... Check out the notes titled “Mikeyyyy, this is how I made it work on Windows 7 64-bit with IIS 7.5 I hope it helps.” a good ways ...
Now that Mix11 is over, Microsoft’s next big conference is Tech-Ed 2011, which happens May 16th through May 19th in Atlanta, GA. Each of Microsoft’s conferences have a theme; Mix is about the Web, PDC is about new and upcoming technologies, and there are many more. The focus of Tech-Ed is on current Microsoft technologies. In other words, you would go there to learn about the software that you can use today to get your work done. If you haven’t been there yet, Atlanta is a nice city and the surrounding ...
I had a major problem this week with an MVC app. All of a sudden, all the styles and images stopped working. Man, I spent hours on this trying all sorts of stuff. I setup a new project and stuff worked. So what the heck is up. Then I started playing around one item at a time to figure out what was going on. Eventually I thought, hm, I was working on debugging routes. So lets try the global.asax file items. Well, a line of code was lurking there that I picked up from the route debugger sample (http://haacked.com/archive... ...
Last week, I was interviewed by Zandra Nilocas from Microsoft Philippines. It was my first time experience to talk about something in front of the camera so it's not surprising that I looked like an idiot in that interview (you know swiveling my chair back and forth without noticing it). Anyway in the interview we talked about ASP.NET WebForms, MVC and Web Matrix in general and just to elaborate a bit of what we talked about and to clarify things out, I have decided to write this post... WebForms ...
There has been quite a furore in the last couple of weeks about a blog article published by David Barrett entitled "CEO Friday: Why we don’t hire .NET programmers". You can find it at http://blog.expensify.com/2... Along with about half the global development community, I tried to post a response, but comments were already closed. I had all but forgotten the article until, a few minutes ago, up popped a daily .NET newsletter with a headline linking ...
Lets say you have a controller method in mvc that looks something like this: <AcceptVerbs(HttpVerbs.P... _ Public Function Action(somedate As String, feature As String, Consultant As String) As ActionResult …Code Return View(RecapView) End Function And RecapView would be some view you have defined that gets shown by action when it finishes. But when you run the app, it says something like “Hey, we can’t find this page called RecapView.aspx “ and so forth. This error occurs because apparently ...
I'm just getting to grips with MVC linq etc etc and came across what looks like a common stumbling block. For the more experienced of you reading this please refrain from shouting "Dumbass" at me. All the tutorials are either Code First examples or they create the database from scratch in the App_Data directory. All well and good for a tutorial that need to be easily portable to the readers computer, but not very helpful when setting up a full scale MVC application. My first problem was my lack of ...
UPDATE: Scott Hanselman has a NuGet package to automate many of these steps and you should check it out, http://www.hanselman.com/bl... This is in continuation with Part 1 of the article, so you may want to check it out before reading this, in case you haven’t already. Next, we need to enable the Global.asax. We will open up the Global.asax and add the following two references in the namespaces ...
UPDATE: Scott Hanselman has a NuGet package to automate many of these steps and you should check it out, http://www.hanselman.com/bl... Today, at Tech Ed India 2011, I delivered this session – Web Forms vs. MVC choosing the right one for web development. Although its a tricky topic, it was worth clarifying some of the patterns to decide between Web Forms and MVC. One of the demo scenarios I took ...
I love TSQL. Its really cool. I have switched gears and now am working an converting a large asp classic project to MVC / vb.net. Interesting. So, I am reworking the sql into a repository set of classes. As I do I need to 1) exec stored procedures to test them and 2) get a list of the parameters to setup sqlclient parameters. Item no 1 is easy. I can just use exec to fire the sproc: exec dbo.someSproc 1,20 And now to get the list of parameters: exec sp_helptext someSproc This give me the sprc in ...
ASP.NET MVC provides many built-in HTML Helpers. With help of HTML Helpers we can reduce the amount of typing of HTML tags for creating a HTML page. For example we use Html.TextBox() helper method it generates html input textbox. Write the following code snippet in MVC View: <%=Html.TextBox("txtName... It generates the following html in output page: <input id="txtName" name="txtName" type="text" value="20" /> List of built-in HTML Helpers provided by ASP.NET MVC. ActionLink() - Links ...
This post is to report some differences when using MVC or IHttpHandlers if you’re attempting to set the Cache-control : max-age or s-maxage value under IIS7.x using the HttpResponse.Cache methods. [UPDATE]: 2011-3-14 – The missing piece was calling Response.Cache.SetSlidingEx... as follows: context.Response.Cache.SetC... context.Response.Cache.SetM... context.Response.ContentType = "image/jpeg"; context.Response.Cache.SetS... ...
Like most developers, I prefer to not have to pick up the mouse if I don’t have to. I use the Executor launcher for almost everything so it’s extremely rare for me to ever click the “Start” button in Windows. I also use shortcuts keys when I can so I don’t have to pick up the mouse. By now most people know that the Package Manager Console that comes with NuGet is PowerShell embedded inside of Visual Studio. It is based on its PowerConsole predecessor which was the first (that I’m aware of) to embed ...
As a post VS2010 SP1 installation activity, I am recompiling all my open source projects. The first is XHTMLFIX at http://xhtmlfix.codeplex.com/ This LGPL project has simple fixes to ASP.NET 2.0/4.0 to achieve XHTML compliance as measured by the W3C tests at http://validator.w3.org/ The XHTML project shows as untrue the commonly held belief that MVP or MVC are necessary for producing XHTML compliant web pages. Incidentally the other supposed advantage of MVP and MVC over web forms of easier testing ...
For those who are interested: The course looks at the features of the ASP.NET MVC 3 framework, including the new Razor View Engine, the new unobtrusive AJAX features, NuGet Package Management and more.. http://www.asp.net/mvc/plur... Technorati Tags: ASP.NET MVC,ASP.NET ...
Yesterday I told Wang Tao, an annoying colleague sitting beside me, about how to make the static content enable the CDN in his website which had just been published on Windows Azure. The approach would be Move the static content, the images, CSS files, etc. into the blob storage. Enable the CDN on his storage account. Change the URL of those static files to the CDN URL. I think these are the very common steps when using CDN. But this morning I found that the new Windows Azure SDK 1.4 and new Windows ...
Theres not a ton of good samples out there on using MVC with VB, so I am going to post some things that I am doing on a project. Lets look at links. I am converting a asp classic app to mvc. One page has an anchor tag which I modified to look like so to point to a controller action: <A style=color:red; HREF='Detail/" & currentItem.IdNumber & "'>" & currentItem.IdNumber & "</A> This resolves out to what looks like the right URL and in fact the detail action is fired. The ...
There are a million plugins for jQuery and when a web forms developer like myself works in MVC making use of them is par-for-the-course! MVC is the way now, web forms are but a memory!! Grids / tables are my focus at the moment. I don’t want to get in to righting reems of css and html, but it’s not acceptable to simply dump a table on the screen, functionality like sorting, paging, fixed header and perhaps filtering are expected behaviour. What isn’t always required though is the massive functionality ...
I ran into this little error with MVC where a bunch of errors showed up about __o not declared. This was driving me nuts. Then I ran across this link that solved it. http://stackoverflow.com/qu... So, the solution is to put this into the top of the page like VS does for your site.master. <%-- The following line works around an ASP.NET compiler warning --%> <%: ""%> But what about other pages? Lets say you have a view that’s using your site ...
(UPDATED 2/26/2011 with higlighted information) I previously blogged on running ASP.Net MVC in an ASP.Net WebForms project. My reference at the time was a freely-available PDF document by Scott Guthrie which covered the setup process in good detail. As I am preparing references to share with our audience at my upcoming talk at the Deerfield Beach Coders Café on March 1st (http://www.fladotnet.com/R... I found a nice blog post by Scott Hanselman on running both ASP.Net 4.0 WebForms ...
As some may have noticed, I have taken a liking to Ruby (and Rails in particular) quite a bit recently. This last weekend I spoke at the NYC Code Camp on a comparison of ASP.NET and Rails as well as an intro to Entity Framework talk. I am speaking at RubyNation in April and have submitted to other ruby conferences around the area and I am also doing a Rails and MongoDB talk at the Philly Code Camp in April. Before you start to think this is my "I'm leaving .NET post", which it isn't so I need to ...
I am scheduled to share on NuGet (http://nuget.codeplex.com/) at the Deerfield Beach Coder’s Café on March 1st, 2011. My goal for this talk is to present demos and content covering how to leverage this new neat utility to easily “package” .Net-based binaries or tools and share them with others, who in-turn, can just as easy reference and readily use that same package in their Visual Studio 2010 .Net projects. Scott Hanselman has recently blogged in great detail on creating NuGet packages. For hosting ...
Applications get data from lots of different sources. The most common is to get data from a database or a web service. Typically, we encapsulate calls to a database in a Repository object and we create some sort of IRepository interface as an abstraction to decouple between layers and enable easier unit testing by leveraging faking and mocking. This works great for database interaction. However, when consuming a RESTful web service, this is is not always the best approach. The WCF Web APIs that are ...
Today's $10 deal of the day at http://www.apress.com/info/... is: Pro ASP.NET MVC 2 Framework, Second Edition The ASP.NET MVC 2 Framework is the latest evolution of Microsoft’s ASP.NET web platform. In this book, you’ll discover MVC’s strengths and weaknesses for yourself—and put your best-learned theory into practice ...
Later this week, I will be heading to our annual South Florida .Net Code Camp, an all-day free “Geek Fest” taking place on February 12th, 2011.This year’s code camp will be conveniently taking place at Nova Southeastern University in Ft Lauderdale. With more than 700 already registered, this year’s event is bound to exceed last year’s registration and attendance. We are also fortunate to have secured the backing of a large number of our kind sponsors, supporters and volunteers, with our efforts led ...
All of us work with Visual Studio (or the free Visual Web Developer Express Edition) for developing web applications targeting ASP.NET / ASP.NET MVC or Silverlight etc., Over the years, Visual Studio has grown to a great extent. From being a simple limited functionality tool in VS.NET 2002 to the multi-faceted, MEF driven Visual Studio 2010, it has come a long way. And as much as Visual Studio supports rapid web development by generating HTML mark up, it also added intellisense for some of the HTML ...
A few months ago I blogged about using Model metadata to render a dynamic UI in MVC 2. The scenario in the post was that we might have a view model where the questions are conditionally displayed and therefore a dynamic UI is needed. To recap the previous post, the solution was to use a custom attribute called [QuestionId] in conjunction with an “ApplicableQuestions” collection to identify whether each question should be displayed. This allowed me to have a view model that looked like this: 1: [UIHint("ScalarQuestion")] ...
Many of my clients are actively using Silverlight 4 and RIA Services to build powerful line of business applications. Getting things set up correctly is critical to being to being able to take full advantage of the RIA services plumbing and when developers struggle with the setup they tend to shy away from the solution as a whole. I’m a big proponent of RIA services and wanted to take the opportunity to share some of my experiences in setting up these types of projects. In late 2010 I presented a ...