Updated Northwind Demo For ASP.NET MVC Beta

asp.net, asp.net mvc, code 0 comments suggest edit

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.

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.

Comments

avatar

46 responses

  1. Avatar for shiju
    shiju May 27th, 2008

    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)"

  2. Avatar for Adrian
    Adrian May 27th, 2008

    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()

  3. Avatar for Martin
    Martin May 27th, 2008

    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

  4. Avatar for Steve
    Steve May 27th, 2008

    I get same errors, referencing from preview 3 didn't change the errors.
    I can run the new preview 3 but not this demo.

  5. Avatar for Johan Danforth
    Johan Danforth May 27th, 2008

    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];
    }

  6. Avatar for Steve
    Steve May 27th, 2008

    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

  7. Avatar for Steve
    Steve May 27th, 2008

    Update: doing a 'clean solution' and rerunning appears to have worked. (after referencing the new assemblies)

  8. Avatar for Haacked
    Haacked May 27th, 2008

    @Steve thanks for figuring it out. Not sure why that would happen.

  9. Avatar for Steve
    Steve May 28th, 2008

    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)

  10. Avatar for Vishal Bharakhda
    Vishal Bharakhda May 28th, 2008

    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

  11. Avatar for Steve
    Steve May 28th, 2008

    Has the need for .mvc still exist with preview 3 ?

  12. Avatar for Angel
    Angel May 28th, 2008

    Hi there, what versions are you using in the demo? are these the sames that are in the folder dependencies?, Thanks!

  13. Avatar for Haacked
    Haacked May 29th, 2008

    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.

  14. Avatar for Bart Plasmeijer
    Bart Plasmeijer May 29th, 2008

    Update the references in northwinddemo\dependecies and the sample will work!
    System.Web.Abstractions
    System.Web.Mvc
    System.Web.Routing

  15. Avatar for Ahtesham
    Ahtesham May 29th, 2008

    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

  16. Avatar for Haacked
    Haacked May 30th, 2008

    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.

  17. Avatar for Lee
    Lee May 30th, 2008

    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??

  18. Avatar for Haacked
    Haacked May 31st, 2008

    We haven't announced any release dates. Probably closer to the fall.

  19. Avatar for Dale
    Dale June 1st, 2008

    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)

  20. Avatar for Chenzidian
    Chenzidian June 2nd, 2008

    error ! The error is: Could not load file or assembly 'System.Web.Mvc' or one of its dependencies.
    Why Updated ?

  21. Avatar for rob
    rob June 4th, 2008

    can you reupload the demo, errors everywhere

  22. Avatar for Katrien
    Katrien June 9th, 2008

    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.

  23. Avatar for Mike
    Mike June 10th, 2008

    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.

  24. Avatar for haacked
    haacked June 13th, 2008

    Try it one last time. I just updated the download.

  25. Avatar for indiekiduk
    indiekiduk June 19th, 2008

    Sorry forgot the code tag in above post.
    [code]
    Found a few bugs:
    For the images to be relative path you need this:
    <img src="&lt;%=Request.ApplicationPath%&gt;/Content/Images/&lt;%=ViewData.Model.ProductID%&gt;.jpg" <br=""/>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]

  26. Avatar for wind~~
    wind~~ June 24th, 2008

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

  27. Avatar for Alan
    Alan July 11th, 2008

    Worked a treat, no problem's ;-)

  28. Avatar for James
    James July 16th, 2008

    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

  29. Avatar for Kris Krause
    Kris Krause July 31st, 2008

    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<httpcontextbase>();
    controller.TempData = new TempDataDictionary(context);

  30. Avatar for Kris Krause
    Kris Krause July 31st, 2008

    Looks like we can wait until Preview 4 is released:
    mhinze.com/testing-tempdata-in-aspnet-mvc-previ...

  31. Avatar for Bruce Sinner
    Bruce Sinner August 24th, 2008

    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<northwindmodel.productsnewviewdata>' does not contain a definition for 'Categories' and no extension method 'Categories' accepting a first argument of type 'System.Web.Mvc.ViewDataDictionary<northwindmodel.productsnewviewdata>' 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

  32. Avatar for svolegov
    svolegov August 27th, 2008

    Sheesh, take down animated ads. They totally ruin reading

  33. Avatar for liu.jiang
    liu.jiang August 31st, 2008

    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

  34. Avatar for Ed
    Ed November 16th, 2008

    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:

  35. Avatar for Pankaj Deharia
    Pankaj Deharia December 5th, 2008

    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)

  36. Avatar for Paolo Izmoto
    Paolo Izmoto December 7th, 2008

    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.
    :)

  37. Avatar for q
    q December 10th, 2008

    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?

  38. Avatar for q
    q December 10th, 2008

    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.

  39. Avatar for Kevin Daly
    Kevin Daly December 12th, 2008

    I'm also getting a StackOverflowException on Edits.
    Sigh.

  40. Avatar for Kevin Daly
    Kevin Daly December 12th, 2008

    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.

  41. Avatar for Chuck Wagner
    Chuck Wagner January 15th, 2009

    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.

  42. Avatar for Sir Hughes
    Sir Hughes February 14th, 2009

    Hi, I'm new to :Net etc., is there a VB version available that runs under Visual Web developer Express edition?
    Thank you, Hughes

  43. Avatar for J.W.
    J.W. February 16th, 2009

    Will you update the sample to the latest release?
    Thanks,
    J.W.

  44. Avatar for Brad
    Brad March 24th, 2009

    I am getting the following:
    'System.Web.HttpRequestBase' does not contain a definition for 'IsMvcAjaxRequest'.........

    Is this a known issue? Fix?

  45. Avatar for haacked
    haacked March 25th, 2009

    That method has been renamed to IsAjaxRequest. I'll need to update my sample.

  46. Avatar for whit537
    whit537 January 10th, 2010

    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.