Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET MVC 2
This is the forum to discuss the Wrox book Professional ASP.NET MVC 2 by Jon Galloway, Scott Hanselman, Phil Haack, Scott Guthrie, Rob Conery; ISBN: Professional ASP.NET MVC 2
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2011, 07:19 PM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default Publishing nerd dinner to server

Another hurdle to get over. At the end of Chapter 1 (page 168) it says,

Quote:
Our initial version of our NerdDinner application is now complete and ready to deploy on the Web
(Figure 1-161).
NOT!!! NerdDinner runs fine in development server. But soon as you publish to a real server and run it, it bombs. Turns out references to javascript is different on a real server.

This won't work when deployed to server.
Code:
<script src="/Scripts/Map.js" type="text/javascript"></script>
This does work when deployed to server.
Code:
<script src= "<%= Url.Content("~/Scripts/Map.js")%>" type="text/javascript"></script>
I also noticed access to database seems to be failing. If you got this working, please post how you did it. Thanks.

Last edited by flyinhawaiian; February 11th, 2011 at 11:50 AM..
 
Old February 10th, 2011, 07:26 PM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

Also, when setting up IIS for the first time, I had to use this tool.

ASP.NET IIS Registration Tool (Aspnet_regiis.exe)
http://msdn.microsoft.com/en-us/library/k6h9cz8h.aspx
 
Old February 11th, 2011, 11:41 AM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

Found this useful article

Walkthrough deploying web application
 
Old February 11th, 2011, 11:42 AM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

Another useful article

How to: Deploy a Database With a Web Application Project
 
Old February 11th, 2011, 12:05 PM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

This is the actual error you'll encounter when you do an action that tries to access the database. If you're hitting the server from another machine, you'll get a different message that hides all the details (for security reasons). So, you have to hit the NerdDinner url on the server itself... go to the physical server and try to access http://localhost/NerdDinner. Then try to find a dinner.

Quote:
Server Error in '/NerdDinner' Application.
--------------------------------------------------------------------------------

Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
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: Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Exception occurs in PaginatedList.cs. While debugging you'll see "The underlying provider failed on Open."
Code:
public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize)
{
	PageIndex = pageIndex;
	PageSize = pageSize;
	TotalCount = source.Count(); // <--- DIES RIGHT HERE.
	TotalPages = (int)Math.Ceiling(TotalCount / (double)PageSize);
	this.AddRange(source.Skip(PageIndex * PageSize).Take(PageSize));
}
Using the call stack, you can back track to DinnersController.cs
Code:
public ActionResult Index(int page = 0)
{
    const int pageSize = 10;

    var upcomingDinners = dinnerRepository.FindUpcomingDinners();

    var paginatedDinners = new PaginatedList<Dinner>(upcomingDinners, page, pageSize); // <-- exception 

    return View(paginatedDinners);
}
upcomingDinners comes from the repository (DinnerRepository.cs) method FindUpcomingDinners() which tries to select data from a NerdDinnerEntities object.

So somehow the connection string isnt right when NerdDinnerEntities is instantiated.
Code:
private NerdDinnerEntities entities = new NerdDinnerEntities();

Last edited by flyinhawaiian; February 11th, 2011 at 12:25 PM..
 
Old February 11th, 2011, 12:47 PM
Friend of Wrox
Points: 539, Level: 8
Points: 539, Level: 8 Points: 539, Level: 8 Points: 539, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Location: Seattle
Posts: 106
Thanks: 1
Thanked 17 Times in 17 Posts
Default

So part of the problem is that we really don't wan't to use SQLExpress in a production environment. What we really want to do is to use visual studio to take our SQLExpress database and create scripts that can be applied to a real SQL server. And, adjust our connection string all in a single developer action (we hope).




Similar Threads
Thread Thread Starter Forum Replies Last Post
NerdDinner Dinner.cs errors (System.ComponentModel.DataAnnotations?) LorenMaxwell BOOK: Professional ASP.NET MVC 2 1 January 2nd, 2011 04:12 AM
Nerd Dinner Help - Page 32 yosofun BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 0 June 20th, 2010 09:44 PM
How do you create "fake" sample dinner if id is read-only veritas27 BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 0 June 8th, 2009 12:46 PM
Error publishing Crystal Reports 12 App To Server Metalore Crystal Reports 1 September 9th, 2008 03:53 AM
Final JT's dinner menu. czambran BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 6 April 7th, 2005 09:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.