Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950
This is the forum to discuss the Wrox book ASP.NET MVC Website Programming Problem Design Solution by Nicholas Berardi, Al Katawazi, and Marco Bellinaso; ISBN: 9780470410950
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 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
 
 
Thread Tools Search this Thread Display Modes
  #41 (permalink)  
Old February 2nd, 2009, 05:45 PM
Wrox Author
 
Join Date: Aug 2008
Location: Pittsford, NY, USA.
Posts: 19
Thanks: 1
Thanked 4 Times in 4 Posts
Send a message via AIM to Al_Katawazi
Default TheBeerHouse MVC Beta 2

Just pushed out the latest installment of TheBeerHouse MVC on codeplex. Lots of bugs havev been resolved and Ecommerce & Paypal integration added. Enjoy!

Al Katawazi
  #42 (permalink)  
Old February 17th, 2009, 08:21 PM
Authorized User
 
Join Date: Dec 2008
Posts: 29
Thanks: 1
Thanked 5 Times in 5 Posts
Default

Hi all,

I just download the latest codes, and after attaching the TheBeerHouse.mdf database, I started the debugging. And I ran into an exception which I believe is a database authorization problem. Here is a brief msg:
==================================================
Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. 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 a failure in starting the process for the user instance. The connection will be closed.

Source Error:

Line 186: public static int GetPublishedArticlesCount(this Table<Article> source, string category)
Line 187: {
Line 188: return GetPublishedArticles(source.Context as TheBeerHouseDataContext, category).Count();
Line 189: }
Line 190:

Stack Trace:

[SqlException (0x80131904): Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.]
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) +4844759
System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj) +194
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
System.Data.SqlClient.SqlInternalConnectionTds.Com pleteLogin(Boolean enlistOK) +35

... the rest snipped.
================================
Not being a SQL server expert, could someone give a simple note of how to add a user to the db? (I am using SQL Sever Management Studio 2008 Express).

TIA
  #43 (permalink)  
Old February 18th, 2009, 10:52 AM
Wrox Author
 
Join Date: Aug 2008
Location: Pittsford, NY, USA.
Posts: 19
Thanks: 1
Thanked 4 Times in 4 Posts
Send a message via AIM to Al_Katawazi
Default SQL Issue

Well you shouldn't of had to attach the mdf file in the first place, the site is configured to automatically do that for you. I suspect what happened is you attached it yourself, and then the progrma attempted to do the same. Check to see you have the connection string in the web.config configured properly. If you want, post it here and I can take a look at it for you :).
  #44 (permalink)  
Old February 18th, 2009, 01:46 PM
Authorized User
 
Join Date: Dec 2008
Posts: 29
Thanks: 1
Thanked 5 Times in 5 Posts
Default

I haven't changed the web.config, here is the string:

<connectionStrings>
<add name="TheBeerHouseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\TheBeerHouse.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
</connectionStrings>

TIA.

P.S. I started the VS by clicking on the TheBeerHouse.csproj file, so the project was started properly.
  #45 (permalink)  
Old February 18th, 2009, 07:59 PM
Authorized User
 
Join Date: Dec 2008
Posts: 29
Thanks: 1
Thanked 5 Times in 5 Posts
Default

Ok, folks, after digging into the error in details and googled msdn's website for the "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.
" error, I came up with the following discussion:

http://social.msdn.microsoft.com/For...-cac99740949b/

and fixed my problem with Mike Wachal of the SQL Express Team's suggestion, I removed the SQLExpress folder my C:\Documents and Settings\<user name>\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data folder, and viola, it works.

I spent over few days on this problem on such a obscure fix, couldn't Microsoft comes up with a more meaningful error message?

P.S. The problem seemed to be the result of the upgrade from SQL Server 2005 to 2008.
  #46 (permalink)  
Old February 20th, 2009, 09:14 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: , , .
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to vantoko
Default

Hi,

Just installed the latest bits.
Upon creation of a new article, I get the following error :


A potentially dangerous Request.Form value was detected from the client (body="<p>this will be the ...").

koen
  #47 (permalink)  
Old February 20th, 2009, 09:23 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: , , .
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via MSN to vantoko
Default

Just found out that Nick blogged about this error :)
http://www.coderjournal.com/2009/02/...ed-aspnet-mvc/

Maybe change it in the next build ?
  #48 (permalink)  
Old March 19th, 2009, 07:32 PM
Authorized User
 
Join Date: Oct 2008
Location: Tel Aviv, , Israel.
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by jiang View Post
Hi, Doug

I looked through the implementation, looks like to be good at asp.net mvc you have to

1. A proficient Javascripter, preferably jQuery
2. Lose all the goodies the drag-and-drop custom controls offered to us in Web Forms (no gridview, no validators for free); you have to hand code all of those with html and javascript. (that's why TDD is so much needed in asp.net MVC; in web forms we don't have to test if gridview or validators have bugs, they are written for us by the good fellows in Microsoft; they are debugged and componentized for us to use for free. Now, I have to do all of that on top of the business logic programming; I guess I need to ask for a big pay-raise :)
Is this correct? No controls? No GridView? Is this temporary till the final release is out, or by design and permanent? FUD?
  #49 (permalink)  
Old March 19th, 2009, 11:25 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

As Yoda once said "You must unlearn what you have learned". ;]

The implementation of MVC that Microsoft provides will be considered by some to be a step backwards in that they way MVC pages are constructed are very similar to how a Classic ASP page would have been constructed. So in typical View (the UI) it will most certainly look something like this (this code can be found in the ViewArticle view in TBH):

aspnet Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/CenterStage.Master"
AutoEventWireup="true" CodeBehind="ViewArticle.aspx.cs" Inherits="TheBeerHouse.Views.Article.View" %>
 
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
<div id="article-view">
<ul>
<li><strong>Rating: </strong>
<%= ViewData.Model.Votes%>
<%= ViewData.Model.Votes == 1 ? "user has" : "users have"%>
rated this article <span id="article-rating-value">
<% if (ViewData.Model.AverageRating > 0) { %><img src="<%= ImageRatingUrl %>" alt="<%= ViewData.Model.AverageRating %>" /><% } %></span></li>
<li><strong>Posted By: </strong>
<%= ViewData.Model.AddedBy%></li>
<li><strong>Views: </strong>this article has been read
<%= ViewData.Model.ViewCount%>
times</li>
<li><strong>Location: </strong>
<%= ViewData.Model.Location%></li>
</ul>
<%= ViewData.Model.Body%>
</div>
<form method="post" action="#" class="rate-article">
<p class="field input">
<h3>
<label for="rating">
What would you rate this article?</label></h3>
<br />
<select name="rating" id="rating">
<option value="0">0 Beers</option>
<option value="1">1 Beers</option>
<option value="2">2 Beers</option>
<option value="3">3 Beers</option>
<option value="4">4 Beers</option>
<option value="5">5 Beers</option>
</select>
<button type="submit" id="rate-button">
Rate</button>
</p>
</form>
<% if (ViewData.Model.CommentsEnabled) { %>
<div id="article-comments">
<h3>Comments</h3>
<% foreach (Comment comment in ViewData.Model.Comments) { %>
<% Html.RenderPartial("~/Views/Shared/Article/CommentItem.ascx", comment); %>
<% } %>
</div>
<form method="post" action="#" class="comment-create">
<input type="hidden" id="articleId" name="articleId" value="<%= ViewData.Model.ArticleID %>" />
<input type="hidden" id="commentId" name="commentId" value="" />
<p class="field input">
<label for="name">
Name</label><br />
<%= Html.TextBox("comment-name", null, new { @maxlength = 256 })%>
<span class="input-message"></span>
</p>
<p class="field input">
<label for="email">
E-Mail</label><br />
<%= Html.TextBox("comment-email", null, new { @maxlength = 256 })%>
<span class="input-message"></span>
</p>
<p class="field input">
<label for="body">
Body</label><br />
<%= Html.TextArea("comment-body", String.Empty)%>
<span class="input-message"></span>
</p>
<hr />
<p>
<button type="submit" id="comment-create-button">
Add Comment</button></p>
</form>
<% } %>
</asp:Content>

What most of you will notice right off the bat is that there is an abundance of server code tied up inside of the UI which was standard practice back in the days of ASP. Further more you will notice the use of multiple Forms which, again, was a practice employed by ASP. In most cases the codebehind for your views will be completely empty (in the case of the view above there is a public propery exposed in the code behind) and, in fact, won't even inherit from Page instead they will inheirt from ViewPage and, in the case of the article code above, it inherits an Enumeration of ViewPage with a type of Article (a view)!

Now before anyone throws their hands up in the air and says WTF you have to understand that this is the POINT of this design pattern. A typical Web Form, while some like to think it implements an MVC pattern, it truly doesnt. The ASPX page is tightly coupled to its code behind, period. This completely defeats the purpose of a seperation of layers and, by the shear nature of MVC, you are granted that seperation. A View is a View is a View. If will always house your UI and, typically, nothing more. It is the Models job to transform that data, and do any necessary processing that needs done before it is sent to the View for display. The Controller can be thought of, bascially, as your DAL.

People that have come to love the RAD evnironment of Visual Studio and love the "just works" nature of web forms will be sad to hear that with MVC:

-You have no ViewState. Data in form controls are good for a single page post + 1. If you want to remember data you have to write code that will physically repopulate a textbox or drop down list.
-You do have controls but not in the sense that you expect. For example a textbox is now represented as: <%= Html.TextBox(....) %>

So on and so forth.

Finally, by FUD, are you referring to Fear, Uncertantiy, and doubt? If so, why?

I will answer your questions to the best of my abilities.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
The Following User Says Thank You to dparsons For This Useful Post:
Avraham Nahir (March 20th, 2009)
  #50 (permalink)  
Old March 20th, 2009, 06:33 AM
Authorized User
 
Join Date: Oct 2008
Location: Tel Aviv, , Israel.
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
Default


I've just thrown my hands up in the air and said WTF!

I understand that MVC's main point is maintenance of large code bases. But I'm not there yet. I'm a single (though married :-) programmer starting to build his one-man-job first web site.

I want RAD. I want third party components. I want separation of my (C#) code and HTML markup. I want a tool that will make me work faster and cleaner.

I think you've just covinced me to give up MVC!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
TheBeerHouse MVC preview ASP.NET MVC Website Programming Problem Design Solution jminatel BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 July 18th, 2009 09:16 AM
chapter 13 - MVC omarosa BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 10 March 25th, 2009 12:00 AM
TBH to MVC Framework rocco50 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 June 23rd, 2008 04:50 PM
mvc datta123 Struts 1 October 26th, 2006 11:00 AM
MVC Design Issue gopalkis J2EE 3 September 21st, 2003 11:15 PM



All times are GMT -4. The time now is 09:59 AM.


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