Updated Northwind Demo For ASP.NET MVC Beta

I updated the template to have the correct assembly references so it should work now out of the box. Sorry about that.

northwindA while ago Scott Hanselman linked to my Northwind sample which itself was spawned from an initial sample that Brad Abrams wrote.

As I like to say (to anyone who will listen)

There ain’t no party like a Northwind Party

So I went and updated my sample to work well with the recently released ASP.NET MVC Preview 3Beta.

Download it here.

What others have said

Requesting Gravatar... shiju May 27, 2008 10:11 PM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
When running the demp application I am getting error "Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)"
Requesting Gravatar... Adrian May 27, 2008 10:46 PM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Same problem here when attempting to run the tests...

Cheers,

Adrian.

TestCase 'UnitTests.Controllers.ProductsControllerTest.CanListProductsByCategoryId'
failed: System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
File name: 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ---> System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A)
The Zone of the assembly that failed was:
MyComputer
at UnitTests.Controllers.ProductsControllerTest.CanListProductsByCategoryId()
Requesting Gravatar... Martin May 28, 2008 1:21 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Same problem, but I fixed it by removing the references to the three MVC assemblies, and adding them again but referencing the ones installed into Program Files\Microsoft ASP.NET\ASP.NET MVC Preview 3\Assemblies
Requesting Gravatar... Steve May 28, 2008 6:08 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
I get same errors, referencing from preview 3 didn't change the errors.

I can run the new preview 3 but not this demo.
Requesting Gravatar... Johan Danforth May 28, 2008 6:17 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Fixing the references makes the project run, but CanUpdateProduct and CanEditProduct tests fail with a NullReferenceException at this part:
void SetInvalid(string key) {
TempData["Error:" + key] = Request.Form[key];
}
Requesting Gravatar... Steve May 28, 2008 9:07 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
I get this error

Could not load file or assembly 'System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

even after referencing the new assemblies
Requesting Gravatar... Steve May 28, 2008 9:14 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Update: doing a 'clean solution' and rerunning appears to have worked. (after referencing the new assemblies)
Requesting Gravatar... Haacked May 28, 2008 9:32 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
@Steve thanks for figuring it out. Not sure why that would happen.
Requesting Gravatar... Steve May 28, 2008 11:25 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
I think have a reason now: Resharper. I suspect that is the problem. One step I did that I later recalled while troubleshooting was that I turned off the add-in.

When Resharper starts, it loads the assemblies. I have a feeling it was still using the older version (My guess)
Requesting Gravatar... Vishal Bharakhda May 28, 2008 3:05 PM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Please could someone help me on how to get rid of the error message that has been mentioned above.

The error is: Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)

I have no idea how to fix this please could someone explain it in clear steps. (as in how do i rereference the assemblies?)

Much appreciated
Vishal
Requesting Gravatar... Steve May 28, 2008 6:27 PM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Has the need for .mvc still exist with preview 3 ?
Requesting Gravatar... Angel May 29, 2008 7:58 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Hi there, what versions are you using in the demo? are these the sames that are in the folder dependencies?, Thanks!
Requesting Gravatar... Haacked May 29, 2008 11:11 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Hi All, I'm at a conference so it's hard for me to have time to fix the demo. It looks like Steve was able to. I'll fix it this Friday. Sorry.

Requesting Gravatar... Bart Plasmeijer May 30, 2008 12:49 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Update the references in northwinddemo\dependecies and the sample will work!

System.Web.Abstractions
System.Web.Mvc
System.Web.Routing
Requesting Gravatar... Ahtesham May 30, 2008 2:39 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
hey every one ,
its strange question but i think i should ask cuz it could help other , i am new in MVC and i am using VS 2008 and MVC3
when i downloaded this code and when i build it after updating the refrence and when i start debugging the programe i get this error
that on default page ; is missing and there was only one line
<% Response.Redirect("~/Products/")%>
so i put ; after this
<% Response.Redirect("~/Products/");%>
and it start working
is this the error or did i do wrong thing i am lil confused , can some one explain me that
Requesting Gravatar... Haacked May 30, 2008 2:55 PM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Hi All, I updated the Northwind sample. Bart hit upon the solution. I just removed project references and then re-added them. THis is what happens when I re-use an older project and just copy new DLLs in there. Sorry about that.
Requesting Gravatar... Lee May 31, 2008 1:44 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
When is MVC going to become 'official' as sorts.. I have noticed theres an MVC Unleashed book coming out in August, so is that the timescale you are looking at??
Requesting Gravatar... Haacked May 31, 2008 11:56 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
We haven't announced any release dates. Probably closer to the fall.
Requesting Gravatar... Dale Jun 01, 2008 6:31 PM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Server Error in '/' Application.
--------------------------------------------------------------------------------

Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
Requesting Gravatar... Chenzidian Jun 02, 2008 8:24 PM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
error ! The error is: Could not load file or assembly 'System.Web.Mvc' or one of its dependencies.
Why Updated ?
Requesting Gravatar... rob Jun 05, 2008 6:59 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
can you reupload the demo, errors everywhere
Requesting Gravatar... Katrien Jun 10, 2008 3:06 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Same issue as most folks here: removing the three references and then re-adding them by pointing to the ASP.NET MVC install path in Program Files solves it. Everything is working fine at my end.
Requesting Gravatar... Mike Jun 11, 2008 4:47 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Project file is borked:

---------------------------
Microsoft Visual Studio
---------------------------
The project file 'D:\NorthwindDemo\NorthwindDemo.csproj' cannot be opened.

The project type is not supported by this installation.
Requesting Gravatar... haacked Jun 13, 2008 4:00 PM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Try it one last time. I just updated the download.
Requesting Gravatar... indiekiduk Jun 20, 2008 8:36 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Sorry forgot the code tag in above post.

[code]
Found a few bugs:

For the images to be relative path you need this:

When running on IIS this hard coded path int ListingByCategory.aspx will break it for two reasons - the path not being relative for when in a sub folder and also when the .mvc is needed:
<%=product.ProductName %>
Change it to:
<%=Html.ActionLink(product.ProductName, "Detail", new { ID=product.ProductID })%>

The Grains/Cereals and Meat/Poultry product links crash it because they have slashes in the generated URLs. How can you fix that? This is the problematic line:
<%= Html.ActionLink(category.CategoryName, "List", new { id=category.CategoryName })%>
[/code]
Requesting Gravatar... wind~~ Jun 25, 2008 12:40 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
to indiekiduk:

Categories.aspx:
<%= Html.ActionLink(category.CategoryName, "List", new { id=category.CategoryName.Replace("/", "@") })%>

ProductsController.cs:
id = id.Replace("@", "/");
Requesting Gravatar... Alan Jul 12, 2008 6:18 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Worked a treat, no problem's ;-)
Requesting Gravatar... James Jul 17, 2008 9:04 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
love the demo, really helping me with taking all of the grunt work out of the code behind that im so used to using. Only question that I have is:

Is using forms the best/only approach for passing information back to the controller for updating purposes?

Thanks,
James
Requesting Gravatar... Kris Krause Aug 01, 2008 8:04 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Johan,

You are correct. The CanUpdateProduct and CanEditProduct unit tests fail... everything else seems to be okay.

For the CanUpdateProduct test you need to add:

formVars.Add("UnitPrice", "3.01");

For the CanEditProduct unit test you need to Mock the TempDataDictionary. Apparently, this following code is not doing the job... so I need to do more research.

var context = new Mock();
controller.TempData = new TempDataDictionary(context);



Requesting Gravatar... Kris Krause Aug 01, 2008 8:11 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Looks like we can wait until Preview 4 is released:

mhinze.com/testing-tempdata-in-aspnet-mvc-previ...
Requesting Gravatar... Bruce Sinner Aug 25, 2008 12:47 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Hi,

I downloaded the demo and when I try to access the controller method "/Products/New" its giving me the following error:

CS1061: 'System.Web.Mvc.ViewDataDictionary' does not contain a definition for 'Categories' and no extension method 'Categories' accepting a first argument of type 'System.Web.Mvc.ViewDataDictionary' could be found (are you missing a using directive or an assembly reference?)

I'm using ASP.NET MVC Preview 4, does anyone have an idea what it may be ?

thanks
Requesting Gravatar... svolegov Aug 28, 2008 8:11 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
Sheesh, take down animated ads. They totally ruin reading
Requesting Gravatar... liu.jiang Sep 01, 2008 12:29 AM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
I use the p3,And the problems is nerver! Thanks Haacked!
But I still puzzles at mvc. Are there any people could I communicata with? My msn is perk_jiang@live.cn
Requesting Gravatar... Ed Nov 16, 2008 12:15 PM
# re: Updated Northwind Demo For ASP.NET MVC Preview 3
This is my problem:

Server Error in '/' Application.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Source Error:

Line 30: public object Categories()
Line 31: {
Line 32: return View("Categories", repository.Categories.ToList());
Line 33: }
Line 34:


Source File: C:\Resources\MVC\northwinddemo-p3\NorthwindDemo\NorthwindDemo\Controllers\ProductsController.cs Line: 32

Stack Trace:
Requesting Gravatar... Pankaj Deharia Dec 06, 2008 2:38 AM
# re: Updated Northwind Demo For ASP.NET MVC Beta
It's nice information here. Me too want's to work with MVC. I am new to MVC but want's to learn it.

Pankaj Deharia
http://emobiletech.blogspot.com (New Technologies In Mobile World)
http://g4recruitmentblog.blogspot.com (Online Test Conduction Information)
Requesting Gravatar... Paolo Izmoto Dec 08, 2008 6:18 AM
# re: Updated Northwind Demo For ASP.NET MVC Beta
Hi Phil,

- Thanks for the demo.
- works well on my dev environment : Visual Studio 2008 Pro edition, ASP.NET MVC Beta, though i had to modify the code a bit to work with LINQ to SQL entity classes.

:)

Requesting Gravatar... q Dec 10, 2008 1:47 PM
# re: Updated Northwind Demo For ASP.NET MVC Beta
Hello,

I can't get the demo to work on the latest version of the framework. I'm getting a "StackOverflowException" when saving on the "Edit Product" screen.

I was trying to implement an edit in my own app and followed the example here, but in both projects I get the same unhandled exception error.

Any ideas?
Requesting Gravatar... q Dec 10, 2008 1:51 PM
# re: Updated Northwind Demo For ASP.NET MVC Beta
Sorry, I should have added that it's the Product parameter in EditProduct (the POST version) that seems to blow up the app.

I was looking to implement this sort of automatic object inference in my own edit method, but again received the same error as mentioned above.

Basically I just want to find a good "edit" scenario example that works, with the simplest possible code, and this would seem to fit the bill.

Thanks for reading.
Requesting Gravatar... Kevin Daly Dec 12, 2008 8:15 PM
# re: Updated Northwind Demo For ASP.NET MVC Beta
I'm also getting a StackOverflowException on Edits.
Sigh.
Requesting Gravatar... Kevin Daly Dec 12, 2008 8:53 PM
# re: Updated Northwind Demo For ASP.NET MVC Beta
I've resolved by stack overflow problem - I changed
[AcceptVerbs("POST")]
public ActionResult EditProduct(int id, Product product)
to:
[AcceptVerbs("POST")]
public ActionResult EditProduct(int id, [Bind(Include="ProductName,UnitPrice")]Product product)
...which stopped the model from chasing its own tail (is the problem here with the EF the navigation properties for link tables? Whatever)
I also thought it didn't make sense to pass the ProductID when redirecting back to Products, so I added an Include("Categories") to the pre-update query and changed the parameter passed back to Products to dbProduct.Categories.CategoryID.
Now everything updates nicely and redisplays the Products list with the updated data.
Requesting Gravatar... Chuck Wagner Jan 16, 2009 12:11 AM
# re: Updated Northwind Demo For ASP.NET MVC Beta
Here is the updated EditProduct POST action if anyone is still having problems getting Phil's demo working.

I integrated Kevin Daly's suggestion of redirecting after the POST to the product list for the current product's category.



[AcceptVerbs("POST")]
public ActionResult EditProduct(int id, [Bind(Include="ProductName,UnitPrice")]Product product) {
NORTHWNDEntities entities = new NORTHWNDEntities();

if (ModelState.IsValid) {

var dbProduct = entities.ProductSet
.Include( "Categories" )
.First(
p => p.ProductID == id
);

dbProduct.ProductName = product.ProductName;
dbProduct.UnitPrice = product.UnitPrice;

entities.SaveChanges();
if (Request.IsMvcAjaxRequest()) {
return Content("Product Updated");
}
else {


return RedirectToAction(
"Products",
new { id = dbProduct.Categories.CategoryID }
);

}
}
entities.Dispose();
entities = null;
return View(product);
}



Note: The redirect to the product list is obviously negated if you are using the EditProductAjax ContentResult view.
Requesting Gravatar... Sir Hughes Feb 14, 2009 11:37 AM
# re: Updated Northwind Demo For ASP.NET MVC Beta
Hi, I'm new to :Net etc., is there a VB version available that runs under Visual Web developer Express edition?

Thank you, Hughes
Requesting Gravatar... J.W. Feb 16, 2009 6:05 PM
# re: Updated Northwind Demo For ASP.NET MVC Beta
Will you update the sample to the latest release?

Thanks,
J.W.
Requesting Gravatar... Brad Mar 25, 2009 8:55 AM
# re: Updated Northwind Demo For ASP.NET MVC Beta
I am getting the following:

'System.Web.HttpRequestBase' does not contain a definition for 'IsMvcAjaxRequest'.........


Is this a known issue? Fix?

Requesting Gravatar... haacked Mar 25, 2009 1:04 PM
# re: Updated Northwind Demo For ASP.NET MVC Beta
That method has been renamed to IsAjaxRequest. I'll need to update my sample.
Requesting Gravatar... whit537 Jan 11, 2010 7:23 AM
# re: Updated Northwind Demo For ASP.NET MVC Beta
Archive: northwinddemo-beta.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of northwinddemo-beta.zip or
northwinddemo-beta.zip.zip, and cannot find northwinddemo-beta.zip.ZIP, period.

What do you have to say?

(will show your gravatar)
Please add 3 and 1 and type the answer here: