Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Upgrading to the latest MVC causes error
Message
 
 
À
23/02/2015 12:30:57
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01615733
Message ID:
01615739
Vues:
23
>>Hi everybody,
>>
>>We upgraded the project to the latest MVC (and other packages to the latest) and now we are unable to run the application. The error comes from the
>>
>>routes.MapMvcAttributeRoutes(); method in the RouteConfig class and the error is
>>
>>Exception Details: System.ArgumentException: Cannot call action method 'System.Web.Mvc.PartialViewResult ErrorView[T](T, System.String, System.String, System.String)' on controller 'SysManager.Web.Areas.AccountingAudit.Controllers.PaymentTypesController' because the action method is a generic method.
>>Parameter name: methodInfo
>>
>>Source Error:
>>
>>
>>Line 14: routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
>>Line 15:
>>Line 16: routes.MapMvcAttributeRoutes();
>>Line 17:
>>Line 18: AreaRegistration.RegisterAllAreas();
>>
>>Source File: c:\_Siriusware\Main\SysManager\SysManager.Web\App_Start\RouteConfig.cs Line: 16
>>
>>Stack Trace:
>>
>>
>>[ArgumentException: Cannot call action method 'System.Web.Mvc.PartialViewResult ErrorView[T](T, System.String, System.String, System.String)' on controller 'SysManager.Web.Areas.AccountingAudit.Controllers.PaymentTypesController' because the action method is a generic method.
>>Parameter name: methodInfo]
>>   System.Web.Mvc.ReflectedActionDescriptor..ctor(MethodInfo methodInfo, String actionName, ControllerDescriptor controllerDescriptor, Boolean validateMethod) +336
>>   System.Web.Mvc.ReflectedActionDescriptor..ctor(MethodInfo methodInfo, String actionName, ControllerDescriptor controllerDescriptor) +45
>>   System.Web.Mvc.Async.<>c__DisplayClass4.<GetActionDescriptorDelegate>b__2(String actionName, ControllerDescriptor controllerDescriptor) +73
>>   System.Web.Mvc.Routing.AttributeRoutingMapper.GetActionDescriptors(ReflectedAsyncControllerDescriptor controller) +240
>>   System.Web.Mvc.Routing.AttributeRoutingMapper.AddRouteEntries(SubRouteCollection collector, IEnumerable`1 controllerTypes, IInlineConstraintResolver constraintResolver, IDirectRouteProvider directRouteProvider) +201
>>   System.Web.Mvc.Routing.AttributeRoutingMapper.MapAttributeRoutes(RouteCollection routes, IEnumerable`1 controllerTypes, IInlineConstraintResolver constraintResolver, IDirectRouteProvider directRouteProvider) +333
>>   System.Web.Mvc.Routing.AttributeRoutingMapper.MapAttributeRoutes(RouteCollection routes, IInlineConstraintResolver constraintResolver, IDirectRouteProvider directRouteProvider) +397
>>   System.Web.Mvc.Routing.AttributeRoutingMapper.MapAttributeRoutes(RouteCollection routes, IInlineConstraintResolver constraintResolver) +192
>>   System.Web.Mvc.RouteCollectionAttributeRoutingExtensions.MapMvcAttributeRoutes(RouteCollection routes) +123
>>   SysManager.Web.RouteConfig.RegisterRoutes(RouteCollection routes) in c:\_Siriusware\Main\SysManager\SysManager.Web\App_Start\RouteConfig.cs:16
>>   SysManager.Web.MvcApplication.Application_Start() in c:\_Siriusware\Main\SysManager\SysManager.Web\Global.asax.cs:26
>>
>>Do you know what should be fixed to make it work? Can you check what do you have in that class?
>>
>>Thanks in advance.
>
>Hmm. Don't think this is related to the latest packages - the behaviour seems to have been that way for a long time. See:
>http://stackoverflow.com/questions/2870116/cannot-call-action-method-system-web-mvc-partialviewresult-foott-on-contro
>
>Bottom line: your ErrorView can't be generic......

Everything worked before the update. Here is what we have in the BaseController:
/// <summary>
        /// Returns a partial view indicating that an error has occurred.
        /// </summary>
        /// <typeparam name="T">The type of view model to use for the view (type must derive from BaseEditViewModel).</typeparam>
        /// <param name="viewModel">The view model to use for the view.</param>
        /// <param name="viewName">The name of the view.</param>
        /// <param name="message">The error message to present in the view.</param>
        /// <param name="errorProperty">The name of a property for which an error should be added to the model state.  This parameter is optional
        /// and if it is not specified, no error will be added to the model state.</param>
        /// <returns>PartialViewResult</returns>
        public PartialViewResult ErrorView<T>(T viewModel, string viewName, string message, string errorProperty = "") where T : BaseEditViewModel
        {
            viewModel.ErrorMessage = message;

            if (!String.IsNullOrEmpty(errorProperty))
            {
                ModelState.AddModelError(errorProperty, message); 
            }

            return PartialView(viewName, viewModel);
        }
What do you have there?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform