I am a beginner to .NET. And I have looked at the several other posts with similar titles asked before. I tried these suggestions (As described below) but didn't help.
I need to use a project built by someone else to test a functionality.
When I build the project I get these two errors.
Severity Code Description Project File Line Suppression State Error CS1061 'RouteCollection' does not contain a definition for 'IgnoreRoute' and no accessible extension method 'IgnoreRoute' accepting a first argument of type 'RouteCollection' could be found
.
Severity Code Description Project File Line Suppression State Error CS1061 'RouteCollection' does not contain a definition for 'MapRoute' and no accessible extension method 'MapRoute' accepting a first argument of type 'RouteCollection' could be found
The offending code is this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace DocumentConverterWebAPI
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
}
First I read this post. RouteCollection' doesn't contain a definition for 'MapMvcAttributeRoutes
The most voted answer states that this is because it requires .NET version 4.5+ and the OP has 4.0 something.
Next I wanted to check the .NET version installed in my machine. In developer command prompt
clrver
Microsoft (R) .NET CLR Version Tool Version 4.6.1055.0
Copyright (c) Microsoft Corporation. All rights reserved.
Versions installed on the machine:
v4.0.30319
It seems I have an 4.0 version.
But when I try to install .NET 4.5.2 I get this error.
I ran the .NET Framework verification utility and it says that 4.5.2 is installed properly.
Project target framework is set to 4.5.2
This post suggests that this might be because of Resharper plugin. MapRoute and IgnoreRoute Up and Vanished RSS
So, I disabled resharper but the errors were still there.
EDITS Screenshots show when I tried installing 4.5.2 version of .NET