c# - Match Route Only if specific Parameter -


i trying create route matches if specific parameter used in url.

for example:

routes.maproute(                 name: "bannerads",                 url: "go/{web}",                 defaults: new { controller = "communicationsalias", action = "bannerads", web = urlparameter.optional }                 ); 

i want url match http://www.domain.com/go/web?=111222

but not http://www.domain.com/go/advertising

how change route function way?

you need make part of url static in route then:

routes.maproute(                 name: "bannerads",                 url: "go/web",                 defaults: new { controller = "communicationsalias", action = "bannerads" }             ); 

and place route above more general one:

routes.maproute(                 name: "bannerads",                 url: "go/{web}",                 defaults: new { controller = "communicationsalias", action = "bannerads", web = urlparameter.optional }                 ); 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -