tags:

views:

257

answers:

3

I have a project that it had been developed under MVC1 and after aa few months ago I upgraded it in MVC2.

Everything was well, uppon the day I needed to format my computer.

And what can goes wrong with a format? I don't know Laughing

I have installed the MVC2 after the formating,I import the existing project, I build it, and no error displayed while it been build, but from the time I've uploaded it in the production server I am getting this error.

Method not found: 'System.Web.Mvc.MvcHtmlString System.Web.Mvc.Html.LinkExtensions.RouteLink(System.Web.Mvc.HtmlHelper, System.String, System.Object)'.

I can't understand what caused the problem.

Certainly I assumed that is have to do with MVC1 and I referenced it, but with no luck again.

Theese are the methods that the problem is came from

public static string PagerLinks(this HtmlHelper htmlHelper, string controllerName,
            string actionName, int pageCount, int pageIndex, string cssClass, string moreTextCssClass,
            string currentPageCssClass, int totalProducts) {
            return PagerLinks(htmlHelper, controllerName, actionName, pageCount, pageIndex, "First",
                "Previous", "Next", "Last", "more pages", cssClass, moreTextCssClass,
                currentPageCssClass, totalProducts);
        }

public static string PagerLinks(this HtmlHelper htmlHelper, string controllerName,
            string actionName, int pageCount, int pageIndex, string firstPage, string previousPage,
            string nextPage, string lastPage, string moreText, string cssClass, string moreTextCssClass,
            string currentPageCssClass, int totalProducts) {
            var builder = new StringBuilder();
            if (String.IsNullOrEmpty(controllerName))
                throw new Exception("controllerName and actionName must be specified for PageLinks.");
            if (pageCount <= 1)
                return String.Empty;


            if (String.IsNullOrEmpty(cssClass)) builder.Append("<div>");
            else builder.Append(String.Format("<div class=\"{0}\">", cssClass));

            builder.Append(string.Format("{0} <b>{1}</b>", "total", totalProducts));
            builder.Append("<br />");

            if (pageIndex != 1) {
                // first page link
                builder.Append(
                        htmlHelper.RouteLink( "First", new {
                            controller = controllerName,
                            action = actionName,
                            id = 1
                        }, new { title = firstPage }
                                            )
                                            );
////
///
more code
///
///
}

This is the call syntax

<%=Html.PagerLinks((string)ViewData["Controller"], "Page", (int)ViewData["TotalPages"], (int)ViewData["Page"], "theCssClass", "theMoreTextCssClass", "theCurrentPageCssClass", (int) ViewData["TotalProducts"])%>

Inside PagerLinks method exists this line that I supposed that this is , as the error message said, the error.

htmlHelper.RouteLink( "First", new {controller = controllerName,action = actionName,id = 1}, new { title = firstPage })

but the I am getting the error only when i call it via

<%=Html.PagerLinks((string)ViewData["Controller"], "Page", (int)ViewData["TotalPages"], (int)ViewData["Page"], "theCssClass", "theMoreTextCssClass", "theCurrentPageCssClass", (int) ViewData["TotalProducts"])%>

if I comment out the above line and replaced it with the below line just for testing, nothing happens

htmlHelper.RouteLink( "First", new {controller = controllerName,action = actionName,id = 1}, new { title = firstPage })

I'll appreciate any suggestions

A: 

Check for any refernces in your web.config and make sure it is referencing v2 for System.Web.MVC.

RedFilter
All the references are redered to MVC2.I'll try to use the MVC futures.Finally the problem firing on ActionLink or RouteLink but only when the HtmlHelper extends.I hope MVC futures to give a solution for my problem
StrouMfios
A: 

I got this myself when updating from MVC1 to MVC2 on:

<%=Html.ActionLink<AccountController>(a=>a.LogOut(),"Logout") %>

If you use MVC Futures (as I did in ActionLink above) or MVC Contrib, don't forget to update these to MVC2. It surely solved my problem.

Good luck/Lasse

Lasse Krantz
I'll implement this.Lets see :)
StrouMfios
A: 

When I had this problem, I updated my version of the System.Web.MVC.dll in C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies and then stopped/restarted my web servers and all was right with the world.

James Fleming
I spent many hours to figure out what caused this and finally I realize that the hosting provider didn't provide me with correct details about the mvc version.They had v.1. When I begged them to update the mvc to v.2 all the problems solved.
StrouMfios