Maproute, querystings and mvc

I have two routes:

routes.MapRoute(
            "FetchVenue",                                     
            "venue/fetchlike/{q}",                                     
            new { controller = "venue", action = "fetchlike" }      
        );

        routes.MapRoute(
            "venue",                                         
            "venue/{venueId}",                                 
            new { controller = "Venue", action = "Index" }   
);

      

URL / place / fetch / test is passed to the correct controller Test url / venue / fetchlike /? Q =, however, is passed to the index action.

I want to pass data as a query string.

What am I doing wrong?

0


source to share


2 answers


Actually the problem was that the route:

 routes.MapRoute( "FetchVenue", "venue/fetchlike/{q}",  new { controller = "venue", action = "fetchlike" });

      

should have been:

 routes.MapRoute( "FetchVenue", "venue/fetchlike",  new { controller = "venue", action = "fetchlike" });

      



The value that would be the URL:

/ place / d = fetchlike test?

as suggested above, shooter.

So, in the case of querysting parameters, you DO NOT DONT define them on the route!

+3


source


On top of my head I do not look like your the URL /venue/fetchlike?q=test

, rather than/venue/fetchlike/?q=test



+2


source







All Articles