I am starting to experience Single Page Aplication on ASP.NET MVC 4, follow the code generate at the TodoItems (commented lines) but I have syntax error.
I follow the step at TodoItem.cs
namespace MvcApplication1.Models
{
// To quickly get started building a Single Page Application based on the following model
// class, build your solution (Build -> Build Solution), then right-click on the "Controllers" folder,
// choose Add -> Controller, and set the following options:
//
// * Controller name: TasksController
// * Template: Single Page Application with read/write actions and views, using Entity Framework
// * Model class: TodoItem (MvcApplication1.Models)
// * Data Context class: Choose <New data context...>, then click OK
//
// Afterwards, launch your application (Debug -> Start Debugging), then browse to the URL /Tasks
// For more information, see http://go.microsoft.com/fwlink/?LinkId=238343
public class TodoItem
{
public int TodoItemId { get; set; }
[Required]
public string Title { get; set; }
public bool IsDone { get; set; }
}
}
After create TasksController I have syntax error in Index.cshtml at line: upshot.metadata(@(Html.Metadata<MvcApplication1.Controllers.MvcApplication1Controller>()));
and line: serviceUrl: "@Url.Content("~/api/MvcApplication1")"
jsiahaan
Contributor
2304 Points
588 Posts
Single Page Application - Syntax error after new project template, creating TasksController
Mar 31, 2012 12:16 PM|LINK
I am starting to experience Single Page Aplication on ASP.NET MVC 4, follow the code generate at the TodoItems (commented lines) but I have syntax error.
I follow the step at TodoItem.cs
namespace MvcApplication1.Models { // To quickly get started building a Single Page Application based on the following model // class, build your solution (Build -> Build Solution), then right-click on the "Controllers" folder, // choose Add -> Controller, and set the following options: // // * Controller name: TasksController // * Template: Single Page Application with read/write actions and views, using Entity Framework // * Model class: TodoItem (MvcApplication1.Models) // * Data Context class: Choose <New data context...>, then click OK // // Afterwards, launch your application (Debug -> Start Debugging), then browse to the URL /Tasks // For more information, see http://go.microsoft.com/fwlink/?LinkId=238343 public class TodoItem { public int TodoItemId { get; set; } [Required] public string Title { get; set; } public bool IsDone { get; set; } } }After create TasksController I have syntax error in Index.cshtml at line: upshot.metadata(@(Html.Metadata<MvcApplication1.Controllers.MvcApplication1Controller>()));
and line: serviceUrl: "@Url.Content("~/api/MvcApplication1")"
Error code:
The Index.cshtml code:
@{ ViewBag.Title = "TodoItems"; Layout = "~/Views/Shared/_SpaLayout.cshtml"; } <div data-bind="visible: editingTodoItem"> @Html.Partial("_Editor") </div> <div data-bind="visible: !editingTodoItem()"> @Html.Partial("_Grid") </div> <div class="message-info message-success" data-bind="flash: { text: successMessage, duration: 5000 }"></div> <div class="message-info message-error" data-bind="flash: { text: errorMessage, duration: 20000 }"></div> <script type="text/javascript" src="@Url.Content("~/Scripts/TodoItemsViewModel.js")"></script> <script type="text/javascript"> $(function () { upshot.metadata(@(Html.Metadata<MvcApplication1.Controllers.MvcApplication1Controller>())); var viewModel = new MyApp.TodoItemsViewModel({ serviceUrl: "@Url.Content("~/api/MvcApplication1")" }); ko.applyBindings(viewModel); }); </script>I have tried on VS11 beta on Windows Server 2008 R2 and Windows 8 Consumer Preview. I am 100% really sure this is the MVC 4 SPA problem.
Any one can help me please?
Indonesian Humanitarian Foundation
jsiahaan
Contributor
2304 Points
588 Posts
Re: Single Page Application - Syntax error after new project template, creating TasksController
Apr 01, 2012 12:25 AM|LINK
Hi all,
Finally I solved it my self by change connectionString from defaultConnection as follow:
Original
Change to:
Indonesian Humanitarian Foundation