asp.net mvc 2 - Query String Routing with Nullable Types -


I have one of those encoded block days that I should know but instead I will ask for some help I have two routes:

  / log in /login?wa=wsignin1.0&wtrealm=http://localhost/MyApp  
action method

access Gives the login page for the first with an HTTP GET - as in the other there is some federated authentication stuff. I have defined two controller methods:

  Public Performance Index (); Public sector index (string wa); Of course, routing is not like this because the empty type makes it obscure, if the value in the data is present in the data, if I say to execute the second method, how can I stop it?  

EDIT: I have temporarily solved the problem with an action method selector. Is this the best way?

  Public category QueryStringAttribute: ActionMethodSelectorAttribute {Public ICollection & lt; String & gt; Key {receive; Private set; } Public QueryStringAttribute (parameter string [] key) {this.Keys = new ReadOnlyCollection & lt; String & gt; (Keys); } Public override bool IsValidForRequest (ControllerContext controllerContext, System.Reflection.MethodInfo MethodInfo) {var requestKeys = controllerContext.HttpContext.Request.QueryString.AllKeys; Var result = keyss.Except (requestKeys, StringComparer.OrdinalIgnoreCase) .ount () == 0; Return result; }}  

I have encountered this problem many times in the past and I think A classic routing problem is what I have done:

Make your work in your controller:

  Public Performance Index (); Public Sector Indicator ForWa (String W);  

Whatever mapping you need to do in your routes define

  routes.MapRoute ("index_route", "login" new {controller = "Log in", action = "index"}); // It is not necessary, but for display purposes routes.MapRoute here ("index_for_wa_route" "login / wa / {or}", new {controller = "login", action = "index", and = {W}});  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -