Asp.net mvc 2 错误RGD定义&;System.Web.Routing.RouteValueDictionary没有扩展方法
我正在4GuysFromRolla网站上学习Scott Mitchell关于在ASP.NET MVC 2中对数据网格进行排序和分页的教程。我收到错误CS1061:“System.Web.Routing.RouteValueDictionary”不包含“AddQueryStringParameters”的定义,并且找不到接受“System.Web.Routing.RouteValueDictionary”类型的第一个参数的扩展方法“AddQueryStringParameters”(是否缺少using指令或程序集引用?)。我不确定是否需要添加dll引用或其他内容。请有人建议如何提前解决这个问题。我还下载了演示,没有问题。PagerLink.ascx文件中有错误..RoutedData.AddQueryStringParameters();//指向此处时出错 RouteValueDictionaryExtensions.cs看起来像这样(这是帮助文件) } Global.asax.cs看起来像这样Asp.net mvc 2 错误RGD定义&;System.Web.Routing.RouteValueDictionary没有扩展方法,asp.net-mvc-2,Asp.net Mvc 2,我正在4GuysFromRolla网站上学习Scott Mitchell关于在ASP.NET MVC 2中对数据网格进行排序和分页的教程。我收到错误CS1061:“System.Web.Routing.RouteValueDictionary”不包含“AddQueryStringParameters”的定义,并且找不到接受“System.Web.Routing.RouteValueDictionary”类型的第一个参数的扩展方法“AddQueryStringParameters”(是否缺少usi
enter code here
namespace GridDemosMVC
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id =
UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
}
}
我还使用了可从microsoft下载的Dynamic.cs文件。您需要使用
语句和加载项PagerLink.ascx文件添加
在2个用户控件(PagerLink.ascx
&SmartLink.ascx
)中引用名称空间web,如下所示
如果更改了现有名称空间,请使用项目的相应名称空间。where?我之所以问这个问题,是因为在演示文件中没有使用no;您需要导入在其中创建扩展方法的命名空间。您也可以将其导入Web.config中以查看。我认为,在共享文件中添加现有项时,文件中发生了一些混乱。所以,当实现addnamespace时,它说我的文件名是GridDemosMVC。我刚刚在重命名这些add名称空间时进行了一次快速重试,并出现了很多错误,因此我得出结论,需要重新启动项目。谢谢你的帮助。在我在专业环境中结束这起事件之前,有一个问题是,是否可以使用第三方文件,如jqGrid或Scott Mitchell提供的手动代码。@Disco:不要重新发明轮子。使用好的第三方库没有错。
enter code here
namespace GridDemosMVC
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id =
UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
}
}