ban.ang53 (7) [Avatar] Offline
#1
Chapter 2 Simple commerce
got error

the view at '~/Views/Home/Index.aspx' must derive from ViewPage, ViewPage<TModel> ...

I am using the code downloaded from Manning site running VS2010 Framework 4.0

error occured in line: httpHandler.ProcessRequest(HttpContext.Current);
of Page_Load event of Default.aspx
mark.seemann (383) [Avatar] Offline
#2
Re: Chpt2 SimpleCommerce Runtime Error
Do you have all the prerequisites installed as outlined in the readme file?
ban.ang53 (7) [Avatar] Offline
#3
Re: Chpt2 SimpleCommerce Runtime Error
which of these should i install

Castle Windsor: http://castleproject.org/
StructureMap: http://structuremap.github.com/structuremap/
Spring.NET: http://www.springframework.net/
Autofac: http://code.google.com/p/autofac/
Unity: http://unity.codeplex.com/

if i remove the test solution, do i need castleproject?
mark.seemann (383) [Avatar] Offline
#4
Re: Chpt2 SimpleCommerce Runtime Error
As the readme file explains, all of these are supplied as NuGet packages, so you shouldn't need to install any of them.

Which version of the code download are you looking at?

There's a "last updated" notice as the last line in ReadMe.txt.
ban.ang53 (7) [Avatar] Offline
#5
Re: Chpt2 SimpleCommerce Runtime Error
I downloaded about 4 days ago from manning download site. so should be the latest.
i am going to reload the project and see if i get the error

what is causing this error?
mark.seemann (383) [Avatar] Offline
#6
Re: Chpt2 SimpleCommerce Runtime Error
Which version of the code download are you looking at?

There should be a "last updated" notice as the last line in ReadMe.txt.
ban.ang53 (7) [Avatar] Offline
#7
Re: Chpt2 SimpleCommerce Runtime Error
this is what the last line in the readme.txt says


(last updated 2011.04.11 while finalizing the manuscript)
mark.seemann (383) [Avatar] Offline
#8
Re: Chpt2 SimpleCommerce Runtime Error
Is ASP.NET MVC 3 (not 1, 2 or 4) installed?
ban.ang53 (7) [Avatar] Offline
#9
Re: Chpt2 SimpleCommerce Runtime Error
No, it's not on the machine I am using
I will go ahead and install it
Perhaps I owe you one

Thanks for taking the time to look over my problem.

I will let you know how it goes
mark.seemann (383) [Avatar] Offline
#10
Re: Chpt2 SimpleCommerce Runtime Error
That could very well be the issue. Good luck smilie
ban.ang53 (7) [Avatar] Offline
#11
Re: Chpt2 SimpleCommerce Runtime Error
Sorry but it did not work. I had MVC3 installed etc. Downloaded the code made it into VS2010 project , compile and ran and it failed. below is the exception:


System.InvalidOperationException was unhandled by user code
Message=The view at '~/Views/Home/Index.aspx' must derive from ViewPage, ViewPage<TModel>, ViewUserControl, or ViewUserControl<TModel>.
Source=System.Web.Mvc
StackTrace:
at System.Web.Mvc.WebFormView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass11.<ProcessRequest>b__10()
at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)
at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext)
at System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext)
at System.Web.Mvc.MvcHttpHandler.VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext)
at System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContextBase httpContext)
at System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContext httpContext)
at System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
at Ploeh.Samples.Commerce.Web.Default.Page_Load(Object sender, EventArgs e) in C:Usersang.R&TDocumentsVisual Studio 2010SimpleCommerceCommerceWebDefault.aspx.cs:line 18
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
mark.seemann (383) [Avatar] Offline
#12
Re: Chpt2 SimpleCommerce Runtime Error
ban.ang53 (7) [Avatar] Offline
#13
Re: Chpt2 SimpleCommerce Runtime Error
Solved the issue and it is due to me referencing System.Web.Mvc of version 2
Now i am having an issue with this line in commercecontrollerfactory.cs
public override IController CreateController(RequestContext requestContext, string controllerName)
{
return this.controllerMap[controllerName](requestContext);
}
where controllername = favicon.ico -

error - given key not present in dictionary
am i missing other files. this looks like an icon file
still ploughing thru your book. i like it a lot
mark.seemann (383) [Avatar] Offline
#14
Re: Chpt2 SimpleCommerce Runtime Error
Good to hear that you solved the problem.

That favicon thing is a known issue with MVC. See e.g. http://stackoverflow.com/questions/6596715/favicon-icon-mvc3-asp-net