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>