Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Professional ASP.NET MVC 2
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 10th, 2011, 06: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 10:50 AM.
Reply With Quote
  #2 (permalink)  
Old February 10th, 2011, 06: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
Reply With Quote
  #3 (permalink)  
Old February 11th, 2011, 10: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
Reply With Quote
  #4 (permalink)  
Old February 11th, 2011, 10: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
Reply With Quote
  #5 (permalink)  
Old February 11th, 2011, 11:05 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

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 11:25 AM.
Reply With Quote
  #6 (permalink)  
Old February 11th, 2011, 11:47 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

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).
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 03: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



All times are GMT -4. The time now is 08:31 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.