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
 
 
Thread Tools Display Modes
  #11 (permalink)  
Old February 27th, 2011, 05:11 AM
Registered User
 
Join Date: Jan 2011
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default Ajax Scripts also works inside <head></head> tags!

Quote:
Originally Posted by flyinhawaiian View Post
Ok one more thing to check. In my notes I put reference to ajax script in Site.Master (this is not in the book).

Try putting this between the <body> </bod> tags.
[code]
<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
[\code\
It also works if you put the previous 2 script references within the <head> and </head> tags inside the Site.Master file!!! :)
  #12 (permalink)  
Old April 6th, 2011, 09:40 PM
Registered User
 
Join Date: Apr 2011
Location: windsor ns
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Skype™ to BrennanFuchs
Default Still need help with this one!

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /RSVP/Register/9


----------------------
-I've moved the Ajax.js script references to site.master as suggested
-checked config for required namespaces
-Not sure what's missing here as even error occurs before it even hops into the RSVPController. Well not totally true it creates the dinnerRepository
Code:
DinnerRepository dinnerRepository = new DinnerRepository();
and then doesn't seem to recognize the Register function.
-I've also out of curiosity removed the HttpPost it THEN recognized the function but returned the content just to it's own page as opposed to the Details page within the rsvpmsg div...


--------------------------------
Code:
  using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NerdDinner.Models;

namespace NerdDinner.Controllers
{
    public class RSVPController : Controller
    {

        DinnerRepository dinnerRepository = new DinnerRepository();

        //
        // AJAX: /Dinners/Register/1

        [Authorize, HttpPost]
        public ActionResult Register(int id)
        {

            Dinner dinner = dinnerRepository.GetDinner(id);

            if (!dinner.IsUserRegistered(User.Identity.Name))
            {
                RSVP rsvp = new RSVP();
                rsvp.AttendeeName = User.Identity.Name;

                dinner.RSVPs.Add(rsvp);
                dinnerRepository.Save();
            }

            return Content("Thanks - we'll see you there!");
        }
    }
}

----------------------

Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<NerdDinner.Models.Dinner>" %>
   

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Dinner: <%: Model.Title %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


<h2><%: Model.Title %></h2>
    <p>
        <strong>When:</strong>
        <%: Model.EventDate.ToShortDateString() %>
         
        <strong>@</strong>
         
        <%: Model.EventDate.ToShortTimeString() %>
    </p>

     <p>
        <strong>Where:</strong>
         <%: Model.Address %>,
          <%: Model.Country%>
    </p>
    <p>
        <strong>Description:</strong>
         <%: Model.Description%>
    </p>
 
    <p>
        <strong>Organizer:</strong>
         <%: Model.HostedBy%>
         (<%: Model.ContactPhone%>)
    </p>

    <div id="rsvpmsg">
    <% if (Request.IsAuthenticated) 
       { %>

        <% if (Model.IsUserRegistered(User.Identity.Name))
           { %>        
    
            <p>You are registered for this event!</p>
    
        <% } 
           else 
           { %>  
    
                <%: Ajax.ActionLink("RSVP for this event", 
                        "Register",
                        "RSVP", 
                        new { id = Model.DinnerID },
                        new AjaxOptions { UpdateTargetId = "rsvpmsg" })%>
        
        <% } %>
    <% } 
       else 
       { %>
            <a href="/Account/Logon">Logon</a> to RSVP for this event.
    <% } %>
    </div>
    
    <% if (Model.IsHostedBy(User.Identity.Name))
       { %>
    <%: Html.ActionLink("Edit Dinner", "Edit", new { id = Model.DinnerID })%> |
    <%: Html.ActionLink("Delete Dinner", "Delete", new { id = Model.DinnerID }) %> |
    <% }%>
    <%: Html.ActionLink("Back to List", "Index") %>

</asp:Content>

Last edited by BrennanFuchs; April 6th, 2011 at 09:56 PM.
  #13 (permalink)  
Old April 7th, 2011, 04:31 AM
Registered User
 
Join Date: Apr 2011
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default PS3 Hacks

I wrote a review of
PS3 Hacks
xbox hacks
psp hacks
  #14 (permalink)  
Old April 7th, 2011, 04:32 AM
saymamohib28
Guest
 
Posts: n/a
Default

I wrote a review of about>>>>>>>
erp definiton
erp definiton
  #15 (permalink)  
Old April 7th, 2011, 11:25 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

BrennanFuchs, when you got the "Server Error in '/' Application." message were you logged in (as a nerd dinner user)? Are you hitting that URL through the javacript or did you manually type that URL in the browser?
  #16 (permalink)  
Old April 7th, 2011, 08:35 PM
Registered User
 
Join Date: Apr 2011
Location: windsor ns
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Skype™ to BrennanFuchs
Default

yes am logged in as user. One not registered to that dinner of course.
I'm simply clicking the 'RSVP to this event' Ajax.Action link URL on the Details page. So not manually typing.

Thanks so much for the help.. this transition is not a smooth one for this dinosaur..
  #17 (permalink)  
Old April 14th, 2011, 08:30 PM
Registered User
 
Join Date: Apr 2011
Location: windsor ns
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Skype™ to BrennanFuchs
Default Issue persists

Whats strange is it I can get it to work but just returning the
return Content("Thanks - we'll see you there!");

text to a blank screen if i remove the HttpPost

[Authorize]

as opposed to
[Authorize, HttpPost]

naturally this is not bringing me back to the view but just to a blank screen with this text.
  #18 (permalink)  
Old April 15th, 2011, 12:50 PM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Seems like you are using unobtrusive java script (check in your web.config: <add key="UnobtrusiveJavaScriptEnabled" value="true" />). To fix it add to your View following script:
Code:
<script src="/Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
Probably you should also specify HttpMethod explicitly:
Code:
                <%: Ajax.ActionLink("RSVP for this event", 
                        "Register",
                        "RSVP", 
                        new { id = Model.DinnerID },
                        new AjaxOptions { UpdateTargetId = "rsvpmsg", HttpMethod = "Post" })%>

Last edited by bahusoid; April 15th, 2011 at 01:04 PM.
  #19 (permalink)  
Old April 15th, 2011, 01:29 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

Still not sure what is causing your problem. I don't recall anyone else having same problem. I would suggest reviewing all steps from the book to see if you missed something somewhere (get lastest .net mvc, all windows updates, security updates, etc.)

Any chance you can post your code in a public place? Then I can at least try to reproduce the problem on my machine and compare code.
  #20 (permalink)  
Old April 19th, 2011, 08:54 PM
Registered User
 
Join Date: Apr 2011
Location: windsor ns
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Skype™ to BrennanFuchs
Default Still no luck

Thanks bahusoid tried you'r suggestion you were correct about the config key entry (unobtrusive) and I've tried adding the script reference and the explicit casting with no change in behavior.

Something to note: i ONLY get this error when i add the HttpPost qualifier to my 'Register' method in the RSVP Controller. [Authorize, HttpPost]

EVEN with the explicit setting of the httppost as suggest by bahusoid in the actionlink if i remove the qualifier it will save the RSVP but not redirect to the div/ajax action control just to a blank screen with the content string. As SOON as I put that HttpPost back [Authorize, HttpPost] it immediately fails out when trying to hop into the Register method.

Without the post it hops in fine and does the save i just dont post back to the detail page but to RSVP/Register/[id] empty screen...

Flyinhawaiian: I've pulled and recopied every code snippet just to be sure :S. I had MVC3 installed before I even started this book. I appreciate all the effort guys, finally have the work comp setup to a degree when i have the time ill be dragging this in to have a second and 3rd set of eyes on this as well.

As for posting it to a public place i could email you my project? if you want to hit me up kweejibow@hotmail.com

Thanks
Brennan
 


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
MSXSL gives error message for "for" inside "select" ilyaz XSLT 1 December 9th, 2010 05:02 PM
Difficulties with "web.config" and "ASPNETDB" CFRham BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 2 July 3rd, 2010 11:19 AM
How to theme the "Browse" button of "FileUpload" control? varunbwj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 October 14th, 2009 02:22 AM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 05:56 AM
Code not going as planned: "icicle" vs "savedinstancestate" joopthecat BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 May 3rd, 2009 04:09 PM



All times are GMT -4. The time now is 05:28 AM.


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