p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional ASP.NET MVC 2 (http://p2p.wrox.com/forumdisplay.php?f=588)
-   -   Publishing nerd dinner to server (http://p2p.wrox.com/showthread.php?t=82551)

flyinhawaiian February 10th, 2011 07:19 PM

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.

flyinhawaiian February 10th, 2011 07:26 PM

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

flyinhawaiian February 11th, 2011 11:41 AM

Found this useful article

Walkthrough deploying web application

flyinhawaiian February 11th, 2011 11:42 AM

Another useful article

How to: Deploy a Database With a Web Application Project

flyinhawaiian February 11th, 2011 12:05 PM

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

flyinhawaiian February 11th, 2011 12:47 PM

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


All times are GMT -4. The time now is 12:29 PM.

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