[Bug][6.0 RTM][vs.net 2010] - @Html.Actionlink with controllers containing hyphens shows incorrect error

Hi there,

In asp.net mvc I set a route handler as following:

public class HyphenatedRouteHandler : MvcRouteHandler
    {
        protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            requestContext.RouteData.Values["controller"] = requestContext.RouteData.Values["controller"].ToString().Replace("-", String.Empty);
            requestContext.RouteData.Values["action"] = requestContext.RouteData.Values["action"].ToString().Replace("-", String.Empty);
            return base.GetHttpHandler(requestContext);
        }
    }


In my routes I set up the following to take advantage of the route handler:

public static void RegisterRoutes(RouteCollection routes)
{ 
           routes.Add(new Route("{controller}/{action}/{id}", new RouteValueDictionary(                new { controller = "Home", action = "Index", id = UrlParameter.Optional }),                new HyphenatedRouteHandler())            );
}


I then want to use the @Html.ActionLink and I get an error:

@Html.ActionLink((string)ViewBag.BMIDescription, "faqs", "info-tracker")


So with the above ActionLink it compiles fine and runs correctly at runtime yet resharper highlights this as error because it expects the controller name to be named "InfoTracker" without the hyphen even though I am registering a new handler for it

Can you please confirm whether this is a bug?

DotnetShadow

2 comments

On 16.07.2011 5:17, Robsworld Private wrote:

Hi there,


Hi!

So with the above ActionLink it compiles fine and runs correctly at runtime yet resharper highlights this as error because it expects the controller name to be named "InfoTracker" without the hyphen even though I am registering a new handler for it

>

Can you please confirm whether this is a bug?


It's not a bug, it's kind of restriction.
ReSharper can't load any user code and execute it, so it emulates known behaviour of MVC (here is standard
MvcRouteHandler). So, I am afraid, currently, there is no way to teach ReSharper to use custom routing.
You are still able to disable our MVC analysis at all and will not be bothered any errors.

0

I have the exact same issue.

It would be great if it was possible to set an option/setting - that when set -  instructs ReSharper to ignore hyphens? So for code inspection purposes, "info-tracker" is considered the same as "infotracker".

 

 

0

Please sign in to leave a comment.